I have made this script with some help from others.
1.php
<html>
<head>
<title>www.yashtech.net</title>
</head>
<body>
<form method = "post" action="2.php">
<p align="center"><a href="http://WWW.YASHTECH.NET">WWW.YASHTECH.NET</a></p>
<p align="left">Registration Form</p>
<p align="left"> </p>
<p align="left">Username :- <input type="text" name="username" size="20"></p>
<p align="left">Password :- <input type="text" name="password1" size="20"></p>
<p align="left">Repeat Password :- <input type="text" name="password2" size="20"></p>
<p align="left">Email Address :- <input type="text" name="email" size="20"></p>
<input type="submit" value="Submit" name="B1">
<input type="reset" value="Reset" name="B2"></p>
</form>
<p align="left"> </p>
<p align="left"> </p>
<p align="left"> </p>
<?php
$error=NULL;
$time=time();
$check_username=mysql_query("select username from members where username='".$_POST['username']."'");
if ( mysql_num_rows($check_username) > 0) { $error .= "Sorry but that username is already being used!<br>"; }
if ($POST['password1'] != $POST['password2']) { $error .= "Sorry but your 2 passwords did not match!<br>"; }
if ( strlen($POST['username']) > 15 ) { $error .= "Sorry but your username cannot be over 15 characters.<br>"; }
if ( empty( $POST['username']) ) { $error.= "You must choose a username!<br>"; }
if ( empty( $POST['password1']) OR empty($POST['password2']) ) { $error.= "You must fill in both password fields!<br>"; }
if ( empty( $_POST['email']) ) { $error .= "You must enter an email address!<br>"; }
if ($error == NULL)
{
mysql_query("insert into members(username,password,email,location,datejoine
d,question1) values('".$POST['username']."','".$POST['password1']."','".$POST['email']."','".$POST['location']."','".$time."','".$_POST['question1']."')");
}
else { $error .= "<br>Please <a href='../register.php'>try again</a>!"; }
?>
</body>
</html>
This is the form . the error which i get is
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/yashtech/public_html/1.php on line 35
U can visit the above code at http://www.yashtech.net/1.php
========================
2.php
<?php
ob_start();
include("./connectdb.php");
$check_login=mysql_query("SELECT COUNT(*) AS is_member FROM members WHERE username='".$POST['username']."' AND password='".$POST['password']."'");
$row=mysql_fetch_assoc($check_login);
if ( $row['is_member'] == 1 )
{
session_register("username");
$username = $_POST['username'];
session_register("password");
$password = $_POST['password'];
session_register("logged_in");
$logged_in = 1;
$login_result = "<b>Thank you for logging in " . $POST['username'] . "</b>";
$login_action = "<b><a href='".$GET['referer']."?topicid=".$HTTP_SESSION_VARS['topicid']."&cat=".$HTTP_SESSION_VARS['cat']."'>Continue</a></b></font>";
header("Location: ".$_GET['referer']."?topicid=".$HTTP_SESSION_VARS['topicid']."&cat=".$HTTP_SESSION_VARS['cat']."");
unset($HTTP_SESSION_VARS['topicid'] $HTTP_SESSION_
VARS['topicid'];
}
else
{
session_register("username");
$username = $_POST['username'];
session_register("password");
$username = $_POST['password'];
session_register("logged_in");
$logged_in = 0;
$login_result = "<font class=style5>Sorry but your username and password combination was incorrect!";
$login_action = "<b><a href='/login.php'>Try Again</a></b></font>";
header("Location: /login.php");
}
?>
The error which i get in the above script is
Parse error: parse error, unexpected T_VARIABLE, expecting ',' or ')' in /home/yashtech/public_html/2.php on line 29
U can check the above script at http://www.yashtech.net/2.php
=============
Please help me and please rectify my above errors and any other if any.
Please
🙂