Hi
I am using Xampp , Php 5.2.6 and phpedit for wiriting code.
i am trying to add the content's from user form and then add then
into the data base.
It check's if submit is clicked or not , Then if any of the field's
are empty -- It should show an error , it shold check if user name is
there in the data base or not...if yes show error message otherwise
insert into database.
I am getting error if any can help me figure what i am doing wrong
if ( ( isset( $_POST['submit'] ) && $_POST['submit'] ) ==
"register" ); {
if ( $_POST['username'] != "" && $_POST['password'] != "" &&
$_POST['first_name'] != "" && $_POST['last_name'] != "" &&
$_POST['email'] != "" ) {
$query = "SELECT username from user_info WHERE username = " .
$_POST['username'] . " ;";
$result = mysql_query( $query ) or die( mysql_error() );
if ( mysql_num_rows != 0 ) {
echo $_POST['username'] . "already in use";
?>
<form action="registe r.php" method="POST">
<?php
form_display(); -- a function to display text box for
username , password m first name,last name , city ,state
?>
<?php
} else {
$query = "INSERT INTO user_info
(username,passw ord,email,first _name,last_name ,city,state) " . "VALUES
('" . $_POST['username'] . "' ,' " . $_POST['password'] . "','" .
$_POST['email'] . "' , ' " . $_POST['first_name'] . "',' " .
$_POST['last_name'] . "
' , ' " . $_POST['city'] . "',' " . $_POST['state'] . "' );";
$result = mysql_query( $query ) or die( mysql_error() );
$_SESSION['user_logged'] = $_POST['username'];
$_SESSION['user_password'] = $_POST['user_password'];
?>
<p>
Thank you, <?php echo $_POST['first_name'];
?for Registering<br>
</p>
<?php
header( "refresh:0 ;URL=index.php" );
die();
}
} else {
?>
<b>The username , Password , Email ,First Name , Last name are
required</b>
<form action="registe r.php" method="POST">
<?php
form_display();
}
?>
<?php } else { -- i am getting an error in this line.
?>
<p>Welcome to the Registration Page
<form action="registe r.php" method="POST">
<?php
form_display();--a function to display text box for username ,
password m first name,last name , city ,state
?>
</p>
<?php
}
?>
</body>
</html>
i have been trying to get it work , if anyone can tell me what i am
doing wrong i would really appreciate it.
Thank's in advance
Baldaris
I am using Xampp , Php 5.2.6 and phpedit for wiriting code.
i am trying to add the content's from user form and then add then
into the data base.
It check's if submit is clicked or not , Then if any of the field's
are empty -- It should show an error , it shold check if user name is
there in the data base or not...if yes show error message otherwise
insert into database.
I am getting error if any can help me figure what i am doing wrong
if ( ( isset( $_POST['submit'] ) && $_POST['submit'] ) ==
"register" ); {
if ( $_POST['username'] != "" && $_POST['password'] != "" &&
$_POST['first_name'] != "" && $_POST['last_name'] != "" &&
$_POST['email'] != "" ) {
$query = "SELECT username from user_info WHERE username = " .
$_POST['username'] . " ;";
$result = mysql_query( $query ) or die( mysql_error() );
if ( mysql_num_rows != 0 ) {
echo $_POST['username'] . "already in use";
?>
<form action="registe r.php" method="POST">
<?php
form_display(); -- a function to display text box for
username , password m first name,last name , city ,state
?>
<?php
} else {
$query = "INSERT INTO user_info
(username,passw ord,email,first _name,last_name ,city,state) " . "VALUES
('" . $_POST['username'] . "' ,' " . $_POST['password'] . "','" .
$_POST['email'] . "' , ' " . $_POST['first_name'] . "',' " .
$_POST['last_name'] . "
' , ' " . $_POST['city'] . "',' " . $_POST['state'] . "' );";
$result = mysql_query( $query ) or die( mysql_error() );
$_SESSION['user_logged'] = $_POST['username'];
$_SESSION['user_password'] = $_POST['user_password'];
?>
<p>
Thank you, <?php echo $_POST['first_name'];
?for Registering<br>
</p>
<?php
header( "refresh:0 ;URL=index.php" );
die();
}
} else {
?>
<b>The username , Password , Email ,First Name , Last name are
required</b>
<form action="registe r.php" method="POST">
<?php
form_display();
}
?>
<?php } else { -- i am getting an error in this line.
?>
<p>Welcome to the Registration Page
<form action="registe r.php" method="POST">
<?php
form_display();--a function to display text box for username ,
password m first name,last name , city ,state
?>
</p>
<?php
}
?>
</body>
</html>
i have been trying to get it work , if anyone can tell me what i am
doing wrong i would really appreciate it.
Thank's in advance
Baldaris
Comment