Hello People,
I have being trying to insert statement into multiple table at once on my database through php but it not working. I then shared the codes into different php scripts based on each table, but I now find out that I was not able to feel the “authorid” automatically by getting the signup.id from the signup code through the php script. Below is the script, please I need help, I have read the “PHP ANTHOLOGY” and the “Build you own database Driven website”, I also have the “simple sql”, my skill has advance allot but I still need help. Your help will be appreciated
contactperson.php
include 'magic_quotes.php';
$link = mysqli_connect('localhost', 'db', 'yesoyes');
if (!$link)
{
$error = 'Sorry we are experiencing some difficulties in creating your account.<br>
Please call our customer care on ---------- to report this error.';
echo $error;
exit();
}
if (!mysqli_select_db($link, 'hifisms'))
{
$error = 'Sorry we are experiencing some difficulties in creating your account.<br>
Please call our customer care on ----------- to report this complain.';
echo $error;
exit();
}
if (isset($_POST['name']))
if (isset($_POST['title']))
if (isset($_POST['gsm']))
if (isset($_POST['email']))
if (isset($_POST['residential']))
{
$name = mysqli_real_escape_string($link, $_POST['name']);
$title = mysqli_real_escape_string($link, $_POST['title']);
$gsm = mysqli_real_escape_string($link, $_POST['gsm']);
$email = mysqli_real_escape_string($link, $_POST['email']);
$residential = mysqli_real_escape_string($link, $_POST['residential']);
$sql = 'INSERT INTO contactperson SET
name="' . $name . '",
title="' . $title . '",
gsm="' . $gsm . '",
email="' . $email . '",
residential="' . $residential . '"
authorid=signup.id';
if (!mysqli_query($link, $sql))
{
$error = 'Sorry we are experiencing some difficulties in creating your account.<br>
Please call our customer care on ---------- to report this problem.:<br> ' . mysqli_error($link);
echo $error;
exit();
}
}
$output = 'Your account has been created.';
echo $output;
signup.php
include 'magic_quotes.php';
$link = mysqli_connect('localhost', 'db', 'yesoyes');
if (!$link)
{
$error = 'Sorry we are experiencing some difficulties in creating your account.<br>
Please call our customer care on --------to report this error.';
echo $error;
exit();
}
if (!mysqli_select_db($link, 'hifisms'))
{
$error = 'Sorry we are experiencing some difficulties in creating your account.<br>
Please call our customer care on ---------- to report this complain.';
echo $error;
exit();
}
if (isset($_POST['username']))
if (isset($_POST['password']))
{
$username = mysqli_real_escape_string($link, $_POST['username']);
$password = mysqli_real_escape_string($link, $_POST['password']);
$sql = 'INSERT INTO signup SET
username="' . $username . '",
password="' . $password . '" ';
if (!mysqli_query($link, $sql))
{
$error = 'Sorry we are experiencing some difficulties in creating your account.<br>
Please call our customer care on ------- to report this problem.:<br> ' . mysqli_error($link);
echo $error;
exit();
}
}
$output = 'Your account has been created.';
echo $output;