You are viewing our Forum Archives. To view or take place in current topics click here.
[PHP] I'm really stuck can anyone fix this?
Posted:
[PHP] I'm really stuck can anyone fix this?Posted:
Status: Offline
Joined: Nov 16, 201113Year Member
Posts: 22
Reputation Power: 0
Status: Offline
Joined: Nov 16, 201113Year Member
Posts: 22
Reputation Power: 0
Picture of Error:
[ Register or Signin to view external links. ]
Coding of the Page :
[ Register or Signin to view external links. ]
Coding of the Page :
<html>
<head>
<title></title>
</head>
<body>
<h3>Register:</h3>
Please fill in the following information<dir><dir>
<form action"register.php" method"post">
<table>
<tr>
<tr>Username:</tr>
<tr><input type"text" name"username"></tr>
</tr>
<tr>
<tr>Password:</tr>
<tr><input type"password" name"password"></tr>
</tr>
<tr>
<tr>Confirm Password:</tr>
<tr><input type"password" name"confirmpassword"></tr>
</tr>
<tr>
<tr colespan"2"><input type"submit" name"submit" value"register"</tr>
<tr></tr>
</tr>
</table>
</form>
<?php
include 'config.php';
mysql_connect($host, $user, $password) or die(mysql_error()%
mysql_select_db($database) or die(mysql_error()%
if ($_POST['submit']) {
//get form data
$myusername = ($_POST['username']);
$mypassword = ($_POST['password']);
$myconfirmpassword = ($_POST['confirmpassword']);
if ( (!$myusername) || (!$mypassword) || (!$myconfirmpassword) ){
echo 'You must enter all fields';
exit;
}
//check if the password & confirm match
if ($mypassword != $myconfirmpassword) {
echo 'Your Password does not match with your confirm password';
exit;
}
//check if the username is already taken
$mycheck = mysql_query(" SELECT * users WHERE username='$myusername'")%
if (mysql_num_rows($mycheck) == 1) {
echo 'The username <b>$myusername</b> is already in use';
exit;
}
//inserting into the database
$sql = " INSERT INTO users ( username, password) VALUES ('$myusername', '$mypassword')";
$result = mysql_query($sql);
echo "You have Successfully Registered, Click <a href="login.php"</a>here to return.";
}
?>
</body>
</html>
#2. Posted:
Status: Offline
Joined: Mar 10, 201113Year Member
Posts: 470
Reputation Power: 18
Status: Offline
Joined: Mar 10, 201113Year Member
Posts: 470
Reputation Power: 18
Well first off, you are missing alot of =
Try that and see if that works. If it doesnt, make a reply with the error.
-ScHmIdTy
<html>
<head>
<title></title>
</head>
<body>
<h3>Register:</h3>
Please fill in the following information<dir><dir>
<form action="register.php" method="post">
<table>
<tr>
<tr>Username:</tr>
<tr><input type="text" name="username"></tr>
</tr>
<tr>
<tr>Password:</tr>
<tr><input type="password" name="password"></tr>
</tr>
<tr>
<tr>Confirm Password:</tr>
<tr><input type="password" name="confirmpassword"></tr>
</tr>
<tr>
<tr colespan="2"><input type="submit" name="submit" value="register"</tr>
<tr></tr>
</tr>
</table>
</form>
<?php
include 'config.php';
mysql_connect($host, $user, $password) or die(mysql_error()%
mysql_select_db($database) or die(mysql_error()%
if ($_POST['submit']) {
//get form data
$myusername = ($_POST['username']);
$mypassword = ($_POST['password']);
$myconfirmpassword = ($_POST['confirmpassword']);
if ( (!$myusername) || (!$mypassword) || (!$myconfirmpassword) ){
echo 'You must enter all fields';
exit;
}
//check if the password & confirm match
if ($mypassword != $myconfirmpassword) {
echo 'Your Password does not match with your confirm password';
exit;
}
//check if the username is already taken
$mycheck = mysql_query(" SELECT * users WHERE username='$myusername'")%
if (mysql_num_rows($mycheck) == 1) {
echo 'The username <b>$myusername</b> is already in use';
exit;
}
//inserting into the database
$sql = " INSERT INTO users ( username, password) VALUES ('$myusername', '$mypassword')";
$result = mysql_query($sql);
echo "You have Successfully Registered, Click <a href="login.php"</a>here to return.";
}
?>
</body>
</html>
Try that and see if that works. If it doesnt, make a reply with the error.
-ScHmIdTy
- 0useful
- 0not useful
#3. Posted:
Status: Offline
Joined: Jun 11, 200915Year Member
Posts: 9,897
Reputation Power: 3160
Motto: "I'l no I grew up to fast speed I no u will be little famous" - Famous_Energy
Motto: "I'l no I grew up to fast speed I no u will be little famous" - Famous_Energy
Status: Offline
Joined: Jun 11, 200915Year Member
Posts: 9,897
Reputation Power: 3160
Motto: "I'l no I grew up to fast speed I no u will be little famous" - Famous_Energy
You seem to have a really hard time with syntax, specifically closing correctly (both in HTML and PHP). I really suggest you practice that before you move on to harder things.
<html>
<head>
<title></title>
</head>
<body>
<h3>Register:</h3>
Please fill in the following information<dir><dir>
<form action"register.php" method"post">
<table>
<tr>
<tr>Username:</tr>
<tr><input type"text" name"username"></tr>
</tr>
<tr>
<tr>Password:</tr>
<tr><input type"password" name"password"></tr>
</tr>
<tr>
<tr>Confirm Password:</tr>
<tr><input type"password" name"confirmpassword"></tr>
</tr>
<tr>
<tr colespan"2"><input type"submit" name"submit" value"register"></tr>
<tr></tr>
</tr>
</table>
</form>
<?php
include 'config.php';
mysql_connect($host, $user, $password) or die(mysql_error());
mysql_select_db($database) or die(mysql_error());
if ($_POST['submit']) {
//get form data
$myusername = ($_POST['username']);
$mypassword = ($_POST['password']);
$myconfirmpassword = ($_POST['confirmpassword']);
if ( (!$myusername) || (!$mypassword) || (!$myconfirmpassword) ){
echo 'You must enter all fields';
exit;
}
//check if the password & confirm match
if ($mypassword != $myconfirmpassword) {
echo 'Your Password does not match with your confirm password';
exit;
}
//check if the username is already taken
$mycheck = mysql_query(" SELECT * users WHERE username='$myusername'");
if(mysql_num_rows($mycheck) == 1){
echo 'The username <b>$myusername</b> is already in use';
exit;
}
//inserting into the database
$sql = "INSERT INTO users ( username, password) VALUES ('$myusername', '$mypassword')";
$result = mysql_query($sql);
echo "You have Successfully Registered, Click <a href=\"login.php\"</a>here to return.";
}
?>
</body>
</html>
- 1useful
- 0not useful
#4. Posted:
Status: Offline
Joined: Oct 07, 201014Year Member
Posts: 247
Reputation Power: 9
Status: Offline
Joined: Oct 07, 201014Year Member
Posts: 247
Reputation Power: 9
These guys are right ^^^^
Your syntax sucks (no offense)
The problem isn't in the line that's throwing the error, but the lines above it. You have incorrectly ended your MySQL connection and testing statements with '%' instead of ');'
Get your syntax right before you go messing with MySQL. If you struggle with PHP syntax, MySQL will be a major pain.
Your syntax sucks (no offense)
The problem isn't in the line that's throwing the error, but the lines above it. You have incorrectly ended your MySQL connection and testing statements with '%' instead of ');'
Get your syntax right before you go messing with MySQL. If you struggle with PHP syntax, MySQL will be a major pain.
- 0useful
- 0not useful
You are viewing our Forum Archives. To view or take place in current topics click here.