View Full Version : Need a very simple form submission script
08-29-2009, 04:51 PM
Could anyone point me in the direction of a REALLY SIMPLE php to mysql form submission script?
Simply, it is for registering an email address and phone number (optional) into my database for membership of a club night.
So i literally want 2 boxes, and they write to 2 columns in a mysql database.
Does anyone have a code snippet or a recommendation of a good tutorial?
I havent done any php for ages and im well out of the loop :(
08-29-2009, 05:05 PM
I wrote something quick for you, which might help you start off with.
It's not perfect, but I think this is what you're looking for.
$email = $_POST['email'];
$phone = $_POST['phone'];
// Error check. You could add more to this.
// For example checking if phone number is supplied, and if it's only integers.
// And if the e-mail address is valid.
echo "Please supply an e-mail address.";
$insertData = mysql_query("INSERT INTO `table_name` (`email`,`phone`) VALUES ('".$email."','".$phone."')") or die(mysql_error());
echo "Thank you!";
echo "<form method=\"POST\">";
echo "E-mail: <input type=\"text\" name=\"email\" /><br />";
echo "Phone number: <input type=\"text\" name=\"phone\" /><br />";
echo "<input type=\"submit\" name=\"formsubmit\" value=\"Submit\" />";
I only added a few lines of comments, feel free to ask, if you need any more help.
09-13-2009, 06:06 PM
thank you for this, im going to try that out and see how it goes, my web server has expired tho so I gotta get that back online!!!
09-13-2009, 10:58 PM
Of course you'd need a database for that example to work. And you'd want to sanitize that data.
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.