Chec db if username is already there
| From: | Gary | Date: | Wed, 18 Oct 2000 15:46:44 +0000 |
| Subject: | Chec db if username is already there | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-20914@lists.php.net to get a copy of this message | ||
Hello,
I am fairly new to php and need some help. I have written a sign-up and
need to find out if the user name and or the email address are already
in the database. The second thing is, I am at the point where I am
trying to write a little more less verbose. Is they a shorter way of
writing the mail function, then what I have.
IT
Gary
//Send Email From Form
$msg = "Your UserName Is:\t$username\n";
$msg .= "Your Password Is:\t$password\n";
$msg .= "Please save this mail for future reference. Thank you for
joining\n\n";
$headers = "From:\"Membership\"<Me@mydomain.com>\n";
mail("$email", "Thanks for joining", $msg, $mailheaders);
//Put The Info In The Database
$db = mysql_connect("localhost","user","password") or die
("couldn't
connect to server");
mysql_select_db("dbname",$db) or die ("couldn't select database");
$sql = "INSERT INTO members(username,password,email) VALUES
('$username','$password','$email')";
$result = mysql_query($sql);
if (!$result) {
echo "<h2>couldn't add record</h2>";
} else {
echo "<center><h1>Thank You $username<br> for
Joining</h1></center>";
}