Lamez Posted June 30, 2008 Share Posted June 30, 2008 what I want to do it make a password gate on my registration page, so you have to have the password to register, well this is not the problem what is, is tell the user the put in the wrong password, for example: user goes to register -> wrong password -> redirects them to password gate, gives them an error -> users tries again. so far here is some sample code I am working with: <?php include ("main/include/session.php"); $date = date("l \\t\h\e jS"); $salt = md5($date); $salt2 = md5($salt); $getlink = $_GET[$salt]; if ($getlink == $salt2) { $error = "yes"; header('Location: npage.php'); }else{ if ($error == ('yes')){ echo "Error Wrong Password<br>"; } echo "Password Gate<br>"; echo '<a href="?'.$salt.'='.$salt2.'">Password</a>'; } ?> but when I click on the link, it returns me like I want it to, but it does not pop up an error like I want, how do I go about doing this? -Thanks Quote Link to comment https://forums.phpfreaks.com/topic/112653-help-make-an-error/ Share on other sites More sharing options...
mikefrederick Posted June 30, 2008 Share Posted June 30, 2008 this will be run: if ($error == ('yes')){ echo "Error Wrong Password<br>"; } because as soon as $error='yes'; you leave the page do header('Location: npage.php?error=1'); and then in npage.php do if($_GET['error']=='1') echo 'Error Wrong Password'; Quote Link to comment https://forums.phpfreaks.com/topic/112653-help-make-an-error/#findComment-578530 Share on other sites More sharing options...
Lamez Posted June 30, 2008 Author Share Posted June 30, 2008 I thought about doing that, but I guess that is the only solution. Quote Link to comment https://forums.phpfreaks.com/topic/112653-help-make-an-error/#findComment-578568 Share on other sites More sharing options...
DarkWater Posted June 30, 2008 Share Posted June 30, 2008 Or, don't redirect and just output it. o-O Quote Link to comment https://forums.phpfreaks.com/topic/112653-help-make-an-error/#findComment-578574 Share on other sites More sharing options...
Lamez Posted June 30, 2008 Author Share Posted June 30, 2008 the mod that I made a dupe thread, but it is ok, here is my code so far, it is not coming out the way I want it to you can have a look her: http://www.lamezz.info/register.php you can see the pw gate is on the register form it self, so here is my code, please help me out, thanks <?php $path = ""; $title = "Register"; $login = "no"; $ban = "no"; include ($path."main/include/cons/head.php"); echo '<p class="header">Register</p>'; //Check to see if admin wants to enable registration $r = mysql_query("SELECT * FROM `pgs`"); $row = mysql_fetch_array($r); if ($row['reg'] == (0)){ echo '<p class="maintext">Register is disabled at the moment.</p>'; }else{ //checks to see if admin wants to enable pw gate $date = date("l \\t\h\e jS"); $salt = md5($date); $salt2 = md5($salt); $getlink = $_GET[$salt]; $r = mysql_query("SELECT * FROM `site_status`"); $row = mysql_fetch_array($r); if($row['pass_on_reg'] == ('1')){ ?> <form action="" method="post" name="pw_gate"> <label> </label> <table width="336" border="0"> <tr> <td colspan="3">Please enter the password to continue</td> </tr> <tr> <td width="79">Password</td> <td width="156"><input name="password" type="password" id="password" maxlength="30"></td> <td width="87"><label> <input type="submit" name="register" id="register" value="Continue"> </label></td> </tr> </table> <label></label> </form> <?php } } if($row['pass_on_reg'] == ('1')){ if ($getlink == $salt2){ if (isset($_POST['register'])){ if ($_POST['password'] == ($row['reg_pass'])){ echo "correct"; }else{ echo "wrong password"; } } } ?> <SCRIPT TYPE="text/javascript"> function numbersonly(myfield, e, dec) { var key; var keychar; if (window.event) key = window.event.keyCode; else if (e) key = e.which; else return true; keychar = String.fromCharCode(key); // control keys if ((key==null) || (key==0) || (key== || (key==9) || (key==13) || (key==27) ) return true; // numbers else if ((("0123456789").indexOf(keychar) > -1)) return true; // decimal point jump else if (dec && (keychar == ".")) { myfield.form.elements[dec].focus(); return false; } else return false; } //--> </SCRIPT> <? if($session->isAdmin()){ ?> <p class="maintext">Please use the <a href=<?php echo $path; ?>_admin/admin.php>Admin Center</a></p> <? }else{ if($session->logged_in){ ?> <p class="maintext">Please Wait! You are loggin</p> <? } else if(isset($_SESSION['regsuccess'])){ /* Registration was successful */ if($_SESSION['regsuccess']){ ?> <p class="maintext">You are now registered, you may <a href="<?php echo $path; ?>index.php">Login</a>.</p> <? } /* Registration failed */ else{ ?> <p class="maintext">Regisration Error.<br /> <a href="register.php">Try Again</a>?</p> <? } unset($_SESSION['regsuccess']); unset($_SESSION['reguname']); } else{ ?> <p class="maintext"> <font color="#FF0000">All fields are required.</font> <form action="<?php echo $path; ?>main/include/process.php" method="POST"> <table width="100%" height="186" border="0"> <tr> <td width="149" height="24">Username</td> <td width="154"><input type="text" name="user" maxlength="30" value="<? echo $form->value("user"); ?>" /></td> <td width="1066"><? echo $form->error("user"); ?></td> </tr> <tr> <td height="24">Password</td> <td><input name="pass" type="password" id="pass" value="<? echo $form->value("pass"); ?>" maxlength="30" /></td> <td rowspan="2"><? echo $form->error("pass"); ?></td> </tr> <tr> <td height="24">ReType Password</td> <td><input name="pass2" type="password" id="pass2" value="<? echo $form->value("pass"); ?>" maxlength="30" /></td> </tr> <tr> <td height="24">E-Mail</td> <td><input type="text" name="email" maxlength="50" value="<? echo $form->value("email"); ?>" /></td> <td><? echo $form->error("email"); ?></td> </tr> <tr> <td height="24">First Name</td> <td><input type="text" name="first" maxlength="50" value="<? echo $form->value("first"); ?>" /></td> <td><? echo $form->error("first"); ?></td> </tr> <tr> <td height="24">Last Name</td> <td><input type="text" name="last" maxlength="50" value="<? echo $form->value("last"); ?>" /></td> <td><? echo $form->error("last"); ?></td> </tr> <tr> <td height="24" colspan="3"><font color="#666666">This will not be shared with anyone, this will only be use if we need to contact you. Ex: 8775551234 (with area code)</font></td> </tr> <tr> <td height="24">Phone Number</td> <td><input name="phone" type="text" id="phone" onkeypress="return numbersonly(this, event)" value="<? echo $form->value("phone"); ?>" maxlength="10" /></td> <td><? echo $form->error("phone"); ?></td> </tr> <tr> <td> </td> <td><input type="hidden" name="subjoin" value="1" /> <input name="submit" type="submit" value="Signup!" /></td> <td align="right"><a href="<?php echo $path; ?>support/forgotpass.php">Forgot Password?</a></td> </tr> </table> </form> </p> </p> <?php if($row['pass_on_reg'] == ('1')){ } } } } include ($path."main/include/cons/foot.php"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/112653-help-make-an-error/#findComment-578641 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.