Jump to content

Submitting forms to and from php using image submit


reyna12

Recommended Posts

It works fine with a normal submit button, but it doesn't appear to be doing anything when i use the image, the cologin page remains blank. Any ideas?


cplogin.php

[code]<?php
  if(!$_POST['login']) {
  exit;
  }
  // Change Domain from form page, <input name="domain" type="hidden" value="utilityservers.net">
  $domain = $_POST['domain'];;
 
  // States that the variable user will be what the user type in to username field
  $user = $_POST['user'];
 
  // States that the variable pass will be what the user type in to password field
  $pass = $_POST['pass'];
 
  // If the user added their domain name to username this will remove it
  $user = str_replace("@$domain","",$user);
 
  switch($logintype){ // You could set this form to log in to others but it is not needed
  case "cpanel": // What to log in to
  $port = "2082"; // Port Number Cpanel Is On
$prefix = "http://"; // Protocol, http or https
$user = $user; // Username is set to username typed in
  break;
  default:
  $port = "2082"; // Port Number Cpanel Is On
$prefix = "http://"; // Protocol, http or https
$user = $user; // Username is set to username typed in
  break;
  }
?>
<html>
<body onLoad="setTimeout('document.forms[0].submit();',10)">
<form action="<?php echo "".$prefix."".$domain.":".$port."/login/"; ?>" method="post">
<input type="hidden" name="user" value="<?php echo $user; ?>">
<input type="hidden" name="pass" value="<?php echo $pass; ?>">
</form>
</body>
</html>
[/code]

The Form:

[code]   <form action="cplogin.php" method="post">
  <input name="domain" type="hidden" value="utilityservers.net">
  <input type="hidden" name="logintype" value="cpanel">

            <table width="171" border="0" cellspacing="1" cellpadding="1">

              <tr>

                <td width="171" height="20" class="sideboxheader"><div align="center">Client  Login </div></td>

              </tr>

              <tr>

                <td class="logintablefor"><table width="100%" border="0" cellspacing="0" cellpadding="0">

                    <tr>

                      <td width="34%">Username:</td>

                      <td width="66%"><input name="user" type="text" size="15" /></td>

                    </tr>

                </table></td>

              </tr>

              <tr>

                <td class="logintablefor"><table width="100%" border="0" cellspacing="0" cellpadding="0">

                    <tr>

                      <td width="34%">Password:</td>

                      <td width="66%"><input name="pass" type="password" size="15" /></td>

                    </tr>

                </table></td>

              </tr>

              <tr>

                <td><div align="center">

                  <label>

                  <input type="image" src="imgs/loginbutton.gif" />

                  </label>

                  <img src="imgs/spacer.gif" width="3" height="8" />

                    <label></label>

                    <a href="javascript:hideshowCommon(document.getElementById('forgotpassword'),'toggle0')"><img src="imgs/forgottenpass.gif" width="98" height="20" border="0" /></a></div></td>

              </tr>

            </table>

          </form>[/code]
Link to comment
Share on other sites

I bet you are using MSIE as your browser. MSIE adds the x and y coordinate to the submitted name.

Put this line at the start of your script to see what is being sent to your script:
[code]<?php
echo '<pre>' . print_r($_POST,true) . '</pre>';
?>[/code]

Be sure you test the script with Firefox also, since, I believe it returns a different value.

Ken
Link to comment
Share on other sites

I have tested in both ie7 and firefox, not working with either but heres the script with that code added

IE7

[code]
Array
(
    [domain] => utilityservers.net
    [logintype] => cpanel
    [user] => utility
    [pass] => *******
    [x] => 22
    [y] => 16
)
[/code]

Firefox: Same as above just different x,y

[code]
    [x] => 30
    [y] => 17
[/code]
Link to comment
Share on other sites

your problem seems to be this statement:
[code]if(!$_POST['login']) {
  exit;
  }[/code]
--you don't seem to have a form name by that name.
--since ted_chou12  suggestion of naming your image tag that name still didn't work, I'd do a test for a different varaible in that statement, like  $_POST['pass'].  Alternately you could just create a hidden field with that value:
[code]<input type="hidden" name="login" value="true">[/code]
Link to comment
Share on other sites

naming the login image shows the new xy variables, login_x and login_y, any suggestions on what i can do with them

Array
(
    [domain] => utilityservers.net
    [logintype] => cpanel
    [user] => utility
    [pass] => *********
    [login_x] => 10
    [login_y] => 14
)

Link to comment
Share on other sites

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.