Jump to content

Submit Form via <a href>


chasethemetal
 Share

Recommended Posts

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...