•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the MySQL section within the Web Development category of DaniWeb, a massive community of 427,229 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,226 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MySQL advertiser: Programming Forums
Views: 9041 | Replies: 1
![]() |
•
•
Join Date: Nov 2004
Posts: 4
Reputation:
Rep Power: 0
Solved Threads: 0
Hi,
I've run into absolute brickwall and am really desprate for your help please. I have a MYSQL Database with two Tables called user_comment and the second user_table. When a user register with the site, their details are kept in the user_table. the second table user_comment is so that users who are registered on the user_table can leave comments which will be passed into the user_comment table. HERE IS THE CODE FOR THE SECOND PART, CHECKING IF A USER'S EMAIL EXIST IN the user_table IF SO, PUX THESE DATA INTO user_comment TABLE. PLEASE CAN ANYONE SPOT WHAT IS WRONG WITH THE CODE???
undefined
<?php require 'db.private'; ?>
<html>
<head>
<title> Gizmo® Electronics - Login</title>
</head>
<body>
<table width="100%">
<tr><td>
<?php
$connection = mysql_connect($hostname,$username,$password);
mysql_select_db($databaseName, $connection);
$submit = $_POST['submit'];
$comment = $_POST['comment'];
$email = $_POST['email'];
if(isset($submit)) {
//if(isset($submit)) {
// check if user exists in the database
$query = mysql_query("SELECT email FROM user_table WHERE email = '".$email."'");
//$num_rows = mysql_num_rows($query_email);
//if(!$num_rows) die('Gizmerror!! Either you have typed your USERNAME and or Your PASSWORD incorrectly or you have not registered to access this pages. <p><font color="red" size="+1"><center> Please Try Again</center> </font></p>');
//mysql_query ( "INSERT INTO user_comment (email, comment) VALUES ('$email', '$comment');
$insert = "INSERT INTO user_comment SET
email = '$email',
comment = '$comment'";
//mysql_query($insert);
//$row_comment = mysql_fetch_Array($query);
die("<META http-equiv=\"Refresh\" content=\"0;url=commentdisplay.php\">");
//die("Thank you for registering. Your Registration was Successful! You can now login");
//$insert = "INSERT INTO user_comment SET
//comment = '$comment'";
//mysql_query($insert);
die("Thank you for registering. Your Registration was Successful! You can now login");
//}
//echo mysql_error();
//mysql_close();
}
?>
<center>
<form action="comment.php" method="post">
<table summary="comment page">
<tr>
<td><label for="comment">Your Comment:</label></td>
<td><textarea name="comment" cols="70" rows="5" wrap="VIRTUAL" id="comment" value="comment"></textarea><br /></td>
</tr>
<tr>
<td><label for="email">Email Address:</label></td>
<td><input type="text" id="email" name="email" value="type ur email here"></td>
</tr>
<tr>
<td><input type="submit" name="submit" /></td>
</tr>
</table>
</form>
<p><a href="home.htm">...or return to our Homepage</a></p>
</td>
</tr>
</table>
</body>
</html>
THANK YOU, I REALLY APPRECIATE YOUR TIME AND EFFORT.
I've run into absolute brickwall and am really desprate for your help please. I have a MYSQL Database with two Tables called user_comment and the second user_table. When a user register with the site, their details are kept in the user_table. the second table user_comment is so that users who are registered on the user_table can leave comments which will be passed into the user_comment table. HERE IS THE CODE FOR THE SECOND PART, CHECKING IF A USER'S EMAIL EXIST IN the user_table IF SO, PUX THESE DATA INTO user_comment TABLE. PLEASE CAN ANYONE SPOT WHAT IS WRONG WITH THE CODE???
undefined
<?php require 'db.private'; ?>
<html>
<head>
<title> Gizmo® Electronics - Login</title>
</head>
<body>
<table width="100%">
<tr><td>
<?php
$connection = mysql_connect($hostname,$username,$password);
mysql_select_db($databaseName, $connection);
$submit = $_POST['submit'];
$comment = $_POST['comment'];
$email = $_POST['email'];
if(isset($submit)) {
//if(isset($submit)) {
// check if user exists in the database
$query = mysql_query("SELECT email FROM user_table WHERE email = '".$email."'");
//$num_rows = mysql_num_rows($query_email);
//if(!$num_rows) die('Gizmerror!! Either you have typed your USERNAME and or Your PASSWORD incorrectly or you have not registered to access this pages. <p><font color="red" size="+1"><center> Please Try Again</center> </font></p>');
//mysql_query ( "INSERT INTO user_comment (email, comment) VALUES ('$email', '$comment');
$insert = "INSERT INTO user_comment SET
email = '$email',
comment = '$comment'";
//mysql_query($insert);
//$row_comment = mysql_fetch_Array($query);
die("<META http-equiv=\"Refresh\" content=\"0;url=commentdisplay.php\">");
//die("Thank you for registering. Your Registration was Successful! You can now login");
//$insert = "INSERT INTO user_comment SET
//comment = '$comment'";
//mysql_query($insert);
die("Thank you for registering. Your Registration was Successful! You can now login");
//}
//echo mysql_error();
//mysql_close();
}
?>
<center>
<form action="comment.php" method="post">
<table summary="comment page">
<tr>
<td><label for="comment">Your Comment:</label></td>
<td><textarea name="comment" cols="70" rows="5" wrap="VIRTUAL" id="comment" value="comment"></textarea><br /></td>
</tr>
<tr>
<td><label for="email">Email Address:</label></td>
<td><input type="text" id="email" name="email" value="type ur email here"></td>
</tr>
<tr>
<td><input type="submit" name="submit" /></td>
</tr>
</table>
</form>
<p><a href="home.htm">...or return to our Homepage</a></p>
</td>
</tr>
</table>
</body>
</html>
THANK YOU, I REALLY APPRECIATE YOUR TIME AND EFFORT.
![]() |
•
•
•
•
•
•
•
•
DaniWeb MySQL Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- how to access accessing PHP variable in JavaScript (PHP)
- How do I install Apache, MySQL, PHP on Linux? (PHP)
- Experience the FASTEST MySQL and PHP Hosting | Starting @ $2.50 per month (Web Hosting Deals)
- FASTEST MySQL and PHP Hosting, [Seeing is Believing] 75% OFF On Any Plan (Web Hosting Deals)
- Hardware Requirements for Fedora, Apache, MySQL and PHP on one machine (*nix Hardware Configuration)
- How Can I Pass A PHP Variable From One .php page to another (PHP)
- MySQL and PHP hosting (Linux Servers and Apache)
Other Threads in the MySQL Forum
- Previous Thread: How many clients can access a PHP script at a time from a MySQL server?
- Next Thread: MySQL, SQL conglutinate date items


Linear Mode