chasethemetal Posted May 27, 2011 Share Posted May 27, 2011 When clicked it sends me to my PHP page, so that works. But the data is not sent to the database. If I have a regular old submit button everything works fine. Why isnt the javascript registering as a submit with the PHP anyone know???-----<form id="myForm" action="phpurl.php" method="post"> <?php require_once('geoplugin.class.php'); $geoplugin = new geoPlugin(); //locate the IP $geoplugin->locate(); echo' <input name="ip" type="hidden" value="'.$geoplugin->ip.'" />' ?> <a href="#" onclick="document.getElementById('myForm').submit();" name="submit">submit</a> <input type="submit" name="submit" value="submit" /> <!--IT WORKS FINE WHEN THE INPUT SUMBIT IS THERE, BUT I CANT USE THIS FOR MY PURPOSE. IT MUST BE ATTACHED TO AN A HREF TAG --></form>----------phpurl.php is this below$con = mysql_connect($hostname, $db_user, $db_password); mysql_select_db($database,$con); if (isset($_REQUEST['submit'])) { $sql="INSERT INTO social (ip)VALUES('$_POST[ip]')";if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } }mysql_close($con) Link to comment Share on other sites More sharing options...
Ingolme Posted May 27, 2011 Share Posted May 27, 2011 You're testing for $_REQUEST['submit']. When you click on the link, that variable isn't sent, so just remove that part or substitute it for something else. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.