
The logic of my code is Suppose that the student is already logged in his account..
there's a page where it restricts a user to enter the page and he needs to register on that page..
without entering any details or it's just a button saying "Ask To Join"..
There's no syntax error.. but it directly goes to verified.php but the user needs to be verified..
to explain it simply, it's just like the YAHOO GROUPS.. where you need to join to access the group..
Please.. people with a good heart.. pls. help me... it will be very much appreciated.. Thank you very much..
- Code: Select all
<?php
mysql_connect("localhost","root","") or die(mysql_error());
mysql_select_db("login") or die(mysql_error());
$errors="";
$message="";
$username = $_COOKIE['ID_my_site'];
if (isset($_POST['submit'])) {
$check = "SELECT $username FROM students";
$result = mysql_query($check) or die(mysql_error());
while($row = mysql_fetch_array($result))
{
$id = $row['id'];
$username = $row['username'];
$namelast = $row['namelast'];
$namefirst = $row['namefirst'];
$namemi = $row['namemi'];
}
$insert = "INSERT INTO pendings (id, username, namelast, namefirst, namemi)
VALUES ($id, $username, $namelast, $namefirst, $namemi)";
$add_member = mysql_query($insert) or die(mysql_error());
if (mysql_affected_rows()==1){
$message .= "<h1>Registered</h1>
<p>Thank you, Please wait for the approval of the faculty teacher who handles the subject.</p>";
}
}
else
{
header("location:verified.php");
}
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<br />
<input type="text" name="username" maxlength="60"value="$namelast"/>
<input type="hidden" name="namelast" maxlength="20" value="$namefirst" />
<input type="hidden" name="namefirst" maxlength="20" value="$namemi" />
<input type="hidden" name="namemi" maxlength="20" value="$username" />
<input type="hidden" name="namemi" maxlength="20" value="$id" />
<center><br /><br /><input type="submit" name="submit" value="Ask to Join" style="width: 100px; height: 30px"/></center>
</form>


