jamichelli Posted April 24, 2009 Share Posted April 24, 2009 I've had some help with a form script, however, the way it is written points toward "localhost" once the form is submitted to a database. My host does not allow "localhost", but I actually have to point the data to the host with all of the db info. This is what I have to start with: if (isset($_POST['subedit'])) { $opMode='gather'; } if (isset($_POST['subapprove'])) { if (isset($_POST['subedit'])) { $opMode='gather'; } if (isset($_POST['subapprove'])) { if (mysql_query("INSERT INTO table SET ...")) { $opMode='added'; } else { $opMode='fail'; } } Would I change it to something like this? if (isset($_POST['subedit'])) { $opMode='gather'; } if (isset($_POST['subapprove'])) { if (isset($_POST['subedit'])) { $opMode='gather'; } if (isset($_POST['subapprove'])) { if $con = mysql_connect("mydb.db.1234567.hostedresource.com","mydb","mypassword"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("mydb", $con); INSERT INTO contact_info (name, email) VALUES ('$_POST[name]','$_POST[email]')"); mysql_close($con); { $opMode='added'; } else { $opMode='fail'; } } Thanks all for your help! Quote Link to comment https://forums.phpfreaks.com/topic/155560-another-form-question/ Share on other sites More sharing options...
.josh Posted April 24, 2009 Share Posted April 24, 2009 Well the first piece of code you have doesn't connect to your database at all. Where is that happening? That's what you would want to change, instead of adding what you did (the 2nd piece of code you posted). If your code was working before with the 'localhost' wherever you were testing it, and now you have to point to somewhere else for this host you are using, all you should have to do is change 'localhost' to the database server specified by your host (according to your 2nd script, it looks like 'mydb.db.1234567.hostedresource.com'). Quote Link to comment https://forums.phpfreaks.com/topic/155560-another-form-question/#findComment-818662 Share on other sites More sharing options...
jamichelli Posted April 24, 2009 Author Share Posted April 24, 2009 Ok, so I guess that there is not script yet for the insert. Where would this go script go? Would this go after the </html> tag in the page code? Quote Link to comment https://forums.phpfreaks.com/topic/155560-another-form-question/#findComment-818695 Share on other sites More sharing options...
.josh Posted April 24, 2009 Share Posted April 24, 2009 Read this tutorial. http://www.phpfreaks.com/tutorial/php-basic-database-handling teaches the basic concepts behind how to do basic database handling. Going from form to database and from database to presenting info, etc... Quote Link to comment https://forums.phpfreaks.com/topic/155560-another-form-question/#findComment-818706 Share on other sites More sharing options...
jamichelli Posted April 24, 2009 Author Share Posted April 24, 2009 Thanks! I'm in the middle of this tutorial right now. Quote Link to comment https://forums.phpfreaks.com/topic/155560-another-form-question/#findComment-818727 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.