alwaysinit said: "Hi again all, I have a .php "join" form and a .php "insert". I don't understand how to position the text that comes from "echo" in the insert file. When a user tries to join using the same e-mail address that an existing member has, the text that comes back to the join form from the insert.php to alert the user he or she has made a boo-boo is stuck at the top of the page. I would like to have these alerts show up in a table cell next to my join form.
:D don't know squat, but at least i'm tryin' huh?:D"
edwin said: "if you show us the code we can tell you exactly where to insert it."
alwaysinit said: "thanks Edwin, here you go.
feel free to tell me everything i'm doing wrong anywhere in this.
The first here is the join form .php, followed by the insert form .php
(oh yeah, see if you can spot why when the user recieves thier
confirm e-mail, thier artist_name is "0" every time. however the password is shown to them. see what ya think. thanks again
#1
----------------------------------------------------------------------------------
peepee
Sign up here.
All fields are required.
#2
------------------------------------------------------------
';
if(!$artist_name){
echo "Artist Name is a required field. Please enter it below. ";
}
if(!$first_name){
echo "First Name is a required field. Please enter it below. ";
}
if(!$last_name){
echo "Last Name is a required field. Please enter it below. ";
}
if(!$password){
echo "Create Password is a required field. Please enter it below. ";
}
if(!$email){
echo "Your E-mail is a required field. Please enter it below. ";
}
if(!$country){
echo "Country is a required field. Please enter it below. ";
}
if(!$province){
echo "Province(state) is a required field. Please enter it below. ";
}
if(!$postal_code){
echo "Postal Code(Zip code) is a required field. Please enter it below. ";
}
if(!$gender){
echo "Gender is a required field. Please enter it below. ";
}
include 'join_form.php';
exit();
}
$sql_email_check = mysql_query("SELECT email FROM members_reg
WHERE email='$email'");
$sql_artist_name_check = mysql_query("SELECT artist_name FROM members_reg
WHERE artist_name='$artist_name'");
$email_check = mysql_num_rows($sql_email_check);
$artist_name_check = mysql_num_rows($sql_artist_name_check);
if(($email_check > 0) || ($artist_name_check > 0)){
echo "Please fix the following errors: ";
if($email_check > 0){
echo "Your email address has already been used by another member
in our database. Please submit a different Email address! ";
unset($email);
}
if($artist_name_check > 0){
echo "The Artist Name you have selected has already been used by another member
in our database. Please choose a different Username! ";
unset($artist_name);
}
include 'join_form.php';
exit();
}
$sql="INSERT INTO members_reg
(artist_name, first_name, last_name, password, email, country, province, postal_code, gender)
VALUES
('$artist_name','$first_name','$last_name','$password','$email','$country',
'$province','$postal_code','$gender')";if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
if(!$sql){
echo 'There has been an error creating your account. Please contact the webmaster.';
} else {
$artist_name = mysql_insert_id();
}
$subject = "Your Membership at xxxxxxxxx!";
$message = "Dear $first_name $last_name,
It's good to have you with us at http://www.xxxxxxxxxx.com!
Go have a snack.
You will be able to login
with the following information:
Artist Name: $artist_name
Password: $password
Thanks!
The Webmaster
This is an automated response, please do not reply!";
mail($email, $subject, $message,
"From: [email]webmaster@xxxxxxxxxxx.com[/email]>\n
X-Mailer: PHP/" . phpversion());
echo 'Your membership information has been mailed to your email address!
When you check it, follow the directions!';
echo "You are now a member of xxxxxxxxxx.com!!";mysql_close($con)
?>"
Developer said: "You could put the form/html in the same file as the database/php code, possibly in its own function. Then if you need to show the form you could call the function with an error parameter and put the error text into the form if it is not empty.
Some other observations:
It is quite messy code and I doubt it is valid XHTML.
It might be a good idea to use and a password confirm box for the password on the form. It stops the 'looking over the shoulder' method of hacking.
You need to take extra steps to ensure your script is secure. Search posts in this forum for information on how to avoid SQL injection hack attacks."