i've built a registration system at home and went to check it on the universty computr.
i had to install apache webserver and php suport, sql database server.
after installing the servers and checking if they are fully works. i tested my php code.
i got forrbiden massage trying to use $_php self in a form action="<? $_phpself?>". the same thing happened when i tried to replace $_php self with the name of the same file (ex: register.php calls himself in the form action)
the opration system is winxp BUT there something there dealing with NOVAL the login window is NOVAL
dose this have to do something with the forbbiden. mayb the user loged dosen't have premmision to use $_phpself or is there something in the apache/php config file?
i didn't messed around with the file all i did is add php support in a cgi mode to apache (couldn't get the addmoudle option to work).
the code works fine on my home computer
Heres the register.php file:
<?php
//session_start();
?>
<html>
<head>
</head>
<body>
<!--HTML form -->
<form action="register.php" method="POST">
User name: <input type="text" name="username"><br><br>
Password: <input type="password" name="password"><br><br>
Confirm password <input type="password" name="passconf"><br><br>
Session: <select NAME="session" SIZE="1" width="30"><br><br>
<option value="" SELECTED>Session number
<option value="1">1
<option value="2">2
<option value="3">3
<option value="4">4
<option value="5">5
<option value="6">6
</select>
Group: <select name="group" size="1" width="30">
<option value="" selected>Group number
<option value="1">1
<option value="2">2
<option value="3">3
<option value="4">4
</select><br><br>
<input type="submit" value="Register">
</form>
<?php
if (($_POST['username'] !='') &&($_POST['password']!='')){//Checks if theres input
include 'sqlconnect.php'; //sql connect and disconnect functions
$link = sql_connect(); //Connect to sql server useing root user. connecting to 'remotelearning' db
//--------------Verification----------------------------------
$username = $_POST['username']; //get username from the form
$result = mysql_query("SELECT * FROM students"); // mayb instade of * i could use SELECT username
while ($row = mysql_fetch_array($result)){ //checks if username exisstes
If ($row['username'] == $username){ // don't need the ['username']
sql_disconnect($link);
die("Username exisstes");
}
}
print"Username ok";
print"<br>";
$password = $_POST['password'];
if ($password !=$_POST['passconf']){
sql_disconnect($link);
die("Password didn't match");
}
print"password confirmed";
$password = md5($password);
print"<br>";
$session=$_POST["session"];
$group=$_POST["group"];
if( $session == null or $group == null){
sql_disconnect($link);
print ("You must select a session and a group number");
die;
}
$query=("INSERT INTO students VALUES ('','$username', '$password','$session','$group') " );
if ($result=mysql_query($query)){
print "Thank you for registrting";
echo "<br><br>";
shell_exec ("md $username");
echo"<a href=login.php> Login</a>";
}
else
die(mysql_error());
//set Session.
}
?>
</body>
</html>












