reyna12 Posted December 9, 2006 Share Posted December 9, 2006 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 https://forums.phpfreaks.com/topic/30031-submitting-forms-to-and-from-php-using-image-submit/ Share on other sites More sharing options...
ted_chou12 Posted December 9, 2006 Share Posted December 9, 2006 does it work adding the name, like this <input type="image" name="login" src="imgs/loginbutton.gif" /> ???try it :DTed Link to comment https://forums.phpfreaks.com/topic/30031-submitting-forms-to-and-from-php-using-image-submit/#findComment-138050 Share on other sites More sharing options...
reyna12 Posted December 9, 2006 Author Share Posted December 9, 2006 Have tried adding name="" yeah didn't work either Link to comment https://forums.phpfreaks.com/topic/30031-submitting-forms-to-and-from-php-using-image-submit/#findComment-138207 Share on other sites More sharing options...
kenrbnsn Posted December 9, 2006 Share Posted December 9, 2006 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]<?phpecho '<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 https://forums.phpfreaks.com/topic/30031-submitting-forms-to-and-from-php-using-image-submit/#findComment-138208 Share on other sites More sharing options...
reyna12 Posted December 9, 2006 Author Share Posted December 9, 2006 I have tested in both ie7 and firefox, not working with either but heres the script with that code addedIE7[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 https://forums.phpfreaks.com/topic/30031-submitting-forms-to-and-from-php-using-image-submit/#findComment-138228 Share on other sites More sharing options...
mainewoods Posted December 10, 2006 Share Posted December 10, 2006 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 https://forums.phpfreaks.com/topic/30031-submitting-forms-to-and-from-php-using-image-submit/#findComment-138281 Share on other sites More sharing options...
reyna12 Posted December 10, 2006 Author Share Posted December 10, 2006 naming the login image shows the new xy variables, login_x and login_y, any suggestions on what i can do with themArray( [domain] => utilityservers.net [logintype] => cpanel [user] => utility [pass] => ********* [login_x] => 10 [login_y] => 14) Link to comment https://forums.phpfreaks.com/topic/30031-submitting-forms-to-and-from-php-using-image-submit/#findComment-138559 Share on other sites More sharing options...
AndyB Posted December 10, 2006 Share Posted December 10, 2006 login_x and login_y represent the x and y co-ordinates referenced to the upper-left corner of the image clicked. If either of them is non-zero it means your login image was clicked ...if ($_POST['login_x']!="") { ... etc Link to comment https://forums.phpfreaks.com/topic/30031-submitting-forms-to-and-from-php-using-image-submit/#findComment-138607 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.