LuciBKen Posted May 16, 2007 Share Posted May 16, 2007 I was wondering if someone could help me with this problem. I have some code that just simply won't work. I need the form called testemailscript.php to take the entered email address and when the submit button is clicked, it should send the entered addresss to my test database. If anyone could take a look and maybe point me towards the problem, I would greatly appreciate it. All scripts are posted below. testemailscript.php: <html> <head> <title>Email Submission Page</title> </head> <body> <form method = "post"> Please enter a valid email address <input type = "text" name = "email" value = ""> <input type = "submit" name = "submit" value = "$_post" </form> <? include insert.php ?> </body> </html> config.php: <?php $dbhost = '###.###.###.###'; $dbuser = '####'; $dbpass = '#####'; $dbname = '#######'; ?> insert.php <?php include 'config.php'; include 'opendb.php'; mysql_select_db($######); $query = "INSERT INTO email (email_address) VALUES ($_post)"; mysql_query($query) or die('Error, insert query failed'); $query = "FLUSH PRIVILEGES"; mysql_query($query) or die('Error, insert query failed'); include 'closedb.php'; ?> opendb.php: <?php $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die (Error connecting to mysql'); mysql_select_db($dbname); ?> closedb.php: <?php mysql_close($conn); ?> This is kinda urgent, so if anyone can help, I would be greatly appreciative. Quote Link to comment https://forums.phpfreaks.com/topic/51681-trying-to-get-a-form-to-submit-an-email-address-to-mysql-database/ Share on other sites More sharing options...
john010117 Posted May 16, 2007 Share Posted May 16, 2007 You didn't specify where the form should send the data to. <html> <head> <title>Email Submission Page</title> </head> <body> <form method="post" action="config.php"> Please enter a valid email address <input type = "text" name = "email" value = ""> <input type = "submit" name = "submit" value = "$_post" </form> <? include insert.php ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/51681-trying-to-get-a-form-to-submit-an-email-address-to-mysql-database/#findComment-254554 Share on other sites More sharing options...
LuciBKen Posted May 16, 2007 Author Share Posted May 16, 2007 So, shold this work? testemailscript.php <html> <head> <title>Email Submission Page</title> </head> <body> <form method = "post" action = "insert.php"> Please enter a valid email address <input type = "text" name = "email" value = ""> <input type = "submit" name = "submit" value = "$_post" </form> <? include insert.php ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/51681-trying-to-get-a-form-to-submit-an-email-address-to-mysql-database/#findComment-254578 Share on other sites More sharing options...
john010117 Posted May 16, 2007 Share Posted May 16, 2007 Also, don't put spaces between the equal sign and the values. NOT: <form method = "post" action = "insert.php"> but this: <form method="post" action="insert.php"> Remove the spaces for all the HTML tags. Quote Link to comment https://forums.phpfreaks.com/topic/51681-trying-to-get-a-form-to-submit-an-email-address-to-mysql-database/#findComment-254586 Share on other sites More sharing options...
LuciBKen Posted May 16, 2007 Author Share Posted May 16, 2007 Cool man, I'll try that. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/51681-trying-to-get-a-form-to-submit-an-email-address-to-mysql-database/#findComment-254593 Share on other sites More sharing options...
LuciBKen Posted May 16, 2007 Author Share Posted May 16, 2007 Still nothing ... it just goes to a blank page after I click the submit button, it doesn't give me an error or anything, I thought it would atleast do that? Quote Link to comment https://forums.phpfreaks.com/topic/51681-trying-to-get-a-form-to-submit-an-email-address-to-mysql-database/#findComment-254596 Share on other sites More sharing options...
LuciBKen Posted May 16, 2007 Author Share Posted May 16, 2007 I guess my question is this: It doesn't seem like all of the scripts are working together, what would be easier for me is if I can just put them all together in one file and maybe set some globals. But, I have no idea if that is going to make a difference. Which is the best method, or does it matter? Really, this is a learning experience for me because it is my first real php script attempt. I can describe exactly what it is suposed to do. When the person enters the email address, it should save it to the database, then send a reply to that email address. As you can see, this is only the first part of the whole picture, I had the replier working yesterday, but still had the same result with the database INSERT. For some reason, certain parts work, but when I throw it all together, it just dies. It makes no sense to me. I think I'm narrowing it down, as far as what the real problem is, it just lies within the database script crap. Any suggestions? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/51681-trying-to-get-a-form-to-submit-an-email-address-to-mysql-database/#findComment-254616 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.