Dmitry Makovetskiyd
Dmitry Makovetskiyd

Reputation: 7053

fail to url encode string

When I type this:

<form method="post"  action="../Thread/thread.php?threadID=".<?php echo $threadID; ?>."&page=".<?php echo $page; ?> > 

I get this:

http://localhost/PoliticalForum/Thread/thread.php?threadID=

how can I encode the variables into the url to avoid such mistakes?

Upvotes: 0

Views: 202

Answers (3)

Patrick Desjardins
Patrick Desjardins

Reputation: 140763

 echo('<form method="post"  action="../Thread/thread.php?threadID=' . $threadID . '&page='  . $page . '">'); 

You had problem with your quotes.

Edit:

$url = sprintf("../Thread/thread.php?threadID=%1s&page=%2s",$threadID,$page);
echo('<form method="post"  action="'.$url .'">'); 

http://php.net/manual/en/function.sprintf.php

Upvotes: 3

David Houde
David Houde

Reputation: 4778

Your quotes are wrong, try this:

<form method="post"  action="../Thread/thread.php?threadID=<?php echo $threadID; ?>&page=<?php echo $page; ?>"> 

Upvotes: 0

Shakti Singh
Shakti Singh

Reputation: 86346

Problem with quotes try this one

<form method="post"  action="../Thread/thread.php?threadID=<?php echo $threadID; ?>&page=<?php echo $page; ?>" >

Upvotes: 2

Related Questions