I have two pages that are part of a user registration script. For simplicity's sake I will call one registration.php and the other validate.php
What I basically would like to do is instead of going from registration.php to validate.php, I would like to call the script from validate.php and use it without leaving registration.php
The following code is a portion of the validate.php code. Here are my questions regarding this page. 1). If I want to call it or include it in registration.php should I make it a function? If so, how would I do that.
2) Can I call the validate page or function through an a href statement? (see registration.php code)
<?php /* Account activation script */
// Get database connection
include 'connlogin.php';
// Create variables from URL.
$userid = $_REQUEST['id'];
$code = $_REQUEST['code'];
$usegrp = $_REQUEST['usegrp'];
$sql = mysql_query("UPDATE users SET activated='1' WHERE userid='$userid' AND password='$code' ");
$sql_doublecheck = mysql_query("SELECT * FROM users WHERE userid='$userid' AND password='$code' AND activated='1'");
$doublecheck = mysql_num_rows($sql_doublecheck);
if($doublecheck == 0){
echo
'<div align="center">
<p> </p>
<p> </p>
<p><font color=red size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>No se ha podido activar su incscripción. Por favor, póngase en contacto con <a href="mailto:jim@mncn.csic.es"><font color="#FFFF00"> el administrador de este servicio.</strong></font></p>
</div>';
} elseif ($doublecheck > 0) {
$sql_lastlogin = mysql_query("UPDATE users SET last_login=now() WHERE userid='$userid'");
echo
'<div align="center">
<p> </p>
<p> </p>
<p> </p>
<p><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Su inscripción ha sido activada correctamente</strong></font></p>
</div>';
echo
'<div align="center"><p align="center"><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Tiene acceso a la base de datos del grupo <font color="#FFFF00">'.$_REQUEST['usegrp'].'<font color="#FFFFFF">. <br><br>Por favor, <a href="log_'.$_REQUEST['usegrp'].'.php"><font color="#FFFF00">login </font></a>ahora.</strong></font></p><p align="center"> </p><p align="center"> </p><p align="center"> </p></div>';
}
else
{
echo "No Match";
}
?>
The following is a portion of the registration.php code. If I can run the validate.php page from the registration page what should the a href statement look like. Also, another important (and my last) question is how do I write the script so that the successful or unsuccessful VALIDATE messages REPLACE the previous displayed messages that were returned upon successful registration.
<?php if (!empty($error_str)) {
// errors have occured, halt execution and show form again.
echo '<p><div align="center"><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">There were errors in the information you entered, they are listed below:</font></div></p>';
echo '<ul>'.$error_str.'</ul>';
// show form again
user_form();
} else {
$sql = "INSERT INTO users (first_name, last_name, email_address, username, password, user_level, signup_date)
VALUES('$first_name', '$last_name', '$email_address', '$username', '$password', '$user_level', NOW())";
@mysql_query($sql) or die(mysql_error().'<p>'.$sql.'</p>');
if (mysql_affected_rows() < 1) {
echo '<table width="300" align="center" cellpadding="3" cellspacing="3">';
echo '<tr><td colspan="2"> </td></tr>';
echo '<tr><td colspan="2"><strong><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">There has been an error creating your account. Please contact the webmaster..</font></strong></td></tr>';
echo '<tr><td colspan="2"> </td></tr>';
echo '</table>';
}
else
{
echo '<table width="300" align="center" cellpadding="3" cellspacing="3">';
echo '<tr><td colspan="2"> </td></tr>';
echo '<tr><td colspan="2"><strong><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">User registered successfully.</font></strong></td></tr>';
echo '<tr><td colspan="2"><strong><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">These are the login and passwords that you must enter to access the database:</font></strong></td></tr>';
echo '<tr><td width="191"><strong><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">Login:
'.$username.' </font></strong></td><td width="86"> </td></tr>';
echo '<tr><td><strong><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">Password:
'.$password.' </font></strong></td><td> </td></tr>';
echo '<tr><td colspan="2"><strong><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">Click
<a href="???????????"><font color="#FFFF00">here</font></a> to validate your account.</font></strong></td></tr>';
echo '<tr><td colspan="2"> </td></tr>';
echo '</table>';
}
}
Many thanks for your help....it is much appreciated.