Jump to content

Need a little help with populating a database


Tunes

Recommended Posts

I have created a Table in mysql named creating_members and i would like to populate it is this code correct

<?php
$link = mysql_connect('localhost', 'root', 'tunes');
if (!$link) {
  die('Could not connect: ' . mysql_error());

}

// make TMP the current db
$db_selected = mysql_select_db('TMP', $link);
if (!$db_selected) {
  die ('Can\'t use TMP Database : ' . mysql_error());

}
else{
      print("Connection Successful to TMP database");
}

//add the new information into the database
$query="INSERT INTO creating_members (first_name,last_name,email_address,country_state,comments) VALUES
('$_POST[first_name]','$_POST[last_name]','$_POST[email_address]','$_POST[country_state]','$_POST[comments]')";
if(!mysql_db_query($dbname,$query,$link_id)) die(mysql_error());
echo " success indatabase entry.";


echo "<br />";
echo "<a href=\"form_page.php\">Click here to return to the form page.</a>";
?>


Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.