Jump to content

[SOLVED] Autonumbers into 3 tables.....


yddib

Recommended Posts

Hi,

I am having a problem assigining an auto number generated in one table to two other tables.

When people register on the site, there is an autonumber generated in the database. I am trying to insert this into 2 other fields in different tables. When I tried this is stopped inserting anything to the database. Please help!

 

<?php 
session_start();
$id = $_SESSION['id'];
?>
<html>
<head>
<title>4grads - Contact Us</title>
<link rel="stylesheet" href="style1.css" type="text/css" />
<style type="text/css">
form.pos {position:absolute; left: 250px}
</style>
<meta HTTP-EQUIV="REFRESH" content="0; url=http://www.4grads.net">
</head>
<body>
<div id="sidebar">
<a href="index.html" /><img src="translogo.jpg" alt="4Grads Logo" /></a><br /><br /><br /><br />
<div id="menu" style="width: 170; height: 220">
</div>

</div>

<div id="content">
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" background="bannercreator-nu2.gif" height="55">
  <tr>
    <td width="5%" height="55" align="center">
<td width="40%" height="55" align="center">
    <font color="#FFFFFF" size="3">Registration Successful</font></td>
    <td width="15%" height="55" align="center"></td>
    <td width="20%" height="55" align="center"> </td>
    <td width="20%" height="55" align="center">
    <font color="#FFFFFF" size="3"></font></td>
    <td width="20%" height="55" align="center">
    <a href="help.html"><font color="#FFFFFF" size="3">Help </font></a></td>
  </tr>
</table>

<?php
  
mysql_connect("host", "user", "pass") or die(mysql_error());
//connects to the blacknight server
mysql_select_db("db")or die(mysql_error());


$fname=$_POST['myname'];
$lname=$_POST['myname1'];
$email=$_POST['myEmail'];
$pass=$_POST['pass'];
$gender=$_POST['gender'];
$birthm=$_POST['birthm'];
$birthd=$_POST['birthd'];
$birthy=$_POST['birthy'];
$address1=$_POST['address1'];
$county=$_POST['county'];
$country=$_POST['country'];
$phone=$_POST['phone'];
$location=$_POST['location'];
$course=$_POST['course'];
$occupation=$_POST['occupation'];


mysql_query("INSERT INTO gradinfo (f_name,l_name,email,pass,gender,birthm,birthd,birthy,address1,county,country,telephone,location)
VALUES ('$fname','$lname','$email','$pass','$gender','$birthm','$birthd','$birthy','$address1','$county','$country','$phone','$location')");//Set SQL
mysql_query("INSERT INTO gradcoll (u_course)
VALUES ('$course')");
mysql_query("INSERT INTO gradcoll (u_id)
VALUES ('$id')");
mysql_query("INSERT INTO gradwork (occupation)
VALUES ('$occupation')");
mysql_query("INSERT INTO gradwork (u_id) 
VALUES ('$id')");

echo '<br /><br />Congratulations!! You have successfully joined <i>4Grads</i>';

echo '<br /><br />Please Login <a href="index.html">HERE</a>'

?>


</body>
</html> 

Link to comment
Share on other sites

I'm guessing you want to do this:

 

mysql_query("INSERT INTO gradinfo (f_name,l_name,email,pass,gender,birthm,birthd,birthy,address1,county,country,telephone,location)
VALUES ('$fname','$lname','$email','$pass','$gender','$birthm','$birthd','$birthy','$address1','$county','$country','$phone','$location')");//Set SQL
mysql_query("INSERT INTO gradcoll (u_course, u_id)
VALUES ('$course', '$id')");
mysql_query("INSERT INTO gradwork (occupation, u_id)
VALUES ('$occupation', '$id')");

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.