View Full Version : PHP can't detect my html form
auriaks
02-20-2010, 01:46 AM
Here is my form:
<form action='$conn' method='POST'>
<input type='image' src='../images/minus.png' name='no' width='13' height='13'/> <img src='../images/stars.jpg' width='$star_wid' height='10' border='0'/> <input type='image' src='../images/plus.jpeg' name='yes' width='13' height='13'/>
</form>
My php lines to detect button are:
if(isset($_POST['no'])) {working 1 system}
if(isset($_POST['yes'])) {working 2 system}
your form action needs to be the location of the php script that processes the form.
Are you trying to dynamically insert a URL for your action? e.g.,
$conn = "/url/to/script.php";
?
If so, you need to echo the variable within php tags (placing the variable directly into your html won't work). Try like this:
<?php
$conn = "/url/to/script.php";
?>
<form action='<?php echo $conn; ?>' method='POST'>
<input type='image' src='../images/minus.png' name='no' width='13' height='13'/>
<img src='../images/stars.jpg' width='$star_wid' height='10' border='0'/>
<input type='image' src='../images/plus.jpeg' name='yes' width='13' height='13'/>
</form>
auriaks
02-20-2010, 02:01 AM
it is... $conn is url detected by the script.
function curPageURL() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}
$conn = curPageURL();
auriaks
02-20-2010, 02:41 AM
or I cant use this url?
djr33
02-20-2010, 02:41 AM
Why would you not just use a relative location? That looks like a lot of extra work. Regardless, if that generates the right url then you still need to use echo and not just $conn.
auriaks
02-20-2010, 02:45 AM
because my url is like:
http://swat.xz.lt/redirect_upload/darbai.php?id1=1&id2=0&id3=1&id4=0
and every id generates itself with the page. (changes) So, if someone submits button, he will be in the same page.
yeah, you just need to echo your variable inside php tags. html won't parse php variables.
You could also simply use
<?php echo $_SERVER['PHP_SELF']; ?>if the processing page is the current page.
auriaks
02-20-2010, 02:51 AM
but I faced problem with this too:
my form is variable :D
$reitingas = "
<form action='$conn' method='POST'>
<input type='image' src='../images/minus.png' name='no' width='13' height='13'/> <img src='../images/stars.jpg' width='$star_wid' height='10' border='0'/> <input type='image' src='../images/plus.jpeg' name='yes' width='13' height='13'/>
</form>
";
Sorry, that I didnt post all my script, but that is why i use $conn
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.