Jump to content


Photo

form that doesn't work in some ways...


  • Please log in to reply
3 replies to this topic

#1 wolfas

wolfas
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 11 July 2006 - 07:14 AM

Hello, i have a problem in this script.
the problem is that this form works then i use submit instead of image and with image this form doesn't work  :-[
<?php
echo "<form action=\"".$_SERVER['PHP_SELF']."\" method=\"POST\">";
if ($_POST['submit'])
{
  echo $user.' '.$pass;
}
else
{
echo "<p><input type=\"text\" name=\"user\" size=5 maxlength=12 value=\"name\"></p>";
echo "<p><input type=\"password\" name=\"pass\" size=7 maxlength=12 value=\"password\"></p>";
echo "<p><input type=\"image\" src=\"image.jpg\" height=\"16\" width=\"24\" border=\"0\" ALT=\"hello\" name=\"submit\"></p>";
echo "</form>";}
?>

#2 Prismatic

Prismatic
  • Members
  • PipPipPip
  • Advanced Member
  • 503 posts
  • LocationSan Diego

Posted 11 July 2006 - 07:22 AM

<?php
if($_POST['_submit_check']){
  echo $_POST['user'].' '.$_POST['pass'];
}else{
	echo "<form action='". $_SERVER['PHP_SELF'] ."' method='POST'>
		  <p><input type='text' name='user' size='5' maxlength='12' value='name'></p>
		  <p><input type='password' name='pass' size='7' maxlength='12' value='password'></p>
		  <p><input type='image' src='image.jpg' height='16' width='24' border='0' ALT='hello' name='submit'></p>
		  <input type='hidden' name='_submit_check' value='1'/> 
		  </form>";
}
?>


#3 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 11 July 2006 - 01:30 PM

The problem occurs because when an image is used for a submit button, the x & y positions in that image are returned to your script. To see what is being returned, put this statement at the start of your script:
<?php
if (isset($_POST))
   echo '<pre>' . print_r($_POST,true) . '</pre>';
?>

Ken

#4 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 11 July 2006 - 02:23 PM

If you still wan't to use an image as a button then change this line:
echo "<p><input type=\"image\" src=\"image.jpg\" height=\"16\" width=\"24\" border=\"0\" ALT=\"hello\" name=\"submit\"></p>";
to this line:
echo "<p><button type='submit' style='border: 0px; padding: 0px;' name='submit' alt='hello'><img src='image.jpg' height='16' width='24' border='0'></button></p>";





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users