Jump to content

Recommended Posts

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>";}
?>
Link to comment
https://forums.phpfreaks.com/topic/14266-form-that-doesnt-work-in-some-ways/
Share on other sites

[code]
<?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>";
}
?>
[/code]
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:
[code]<?php
if (isset($_POST))
  echo '<pre>' . print_r($_POST,true) . '</pre>';
?>[/code]

Ken
If you still wan't to use an image as a button then change this line:[code]echo "<p><input type=\"image\" src=\"image.jpg\" height=\"16\" width=\"24\" border=\"0\" ALT=\"hello\" name=\"submit\"></p>";[/code] to this line:[code]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>";[/code]
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.