Mythic Fr0st Posted January 11, 2007 Share Posted January 11, 2007 Currently, my "Mailed" function, which when you sign up, checks if your username, is less than 5, if it is, it sets a boolean to false, and at the end I have if (Bool[1] && Bool[2] == true) and so on...so it wont go through, IF... that doesn't check out properly...However... the only 3 out of 6, that show up areUsername is too shortPassword too shortConfirm Password too shortBUT, even if they're 5 characters or more, it still shows!it should beUsername is too shortPassword is too shortConfirm Password is too shortPasswords do not matchEmails do not matchTerms and Conditions box has not been tickedif anyone can tell me why this is happening, I'll greatly appreciate it... Considering some how it just stopped working (was working before O_O, and i didnt change anything I dont think!)CODE:[code]<?php session_start(); ?><html><head><style type="text/css">body {background-image:url('SilverBG.jpg')}</style></head><DIV STYLE='Position: absolute; top: 0; left: 0;'><!--<img src="Mythic Aeons Banner.jpg" width="1024" height="112">--></div><body><br /><br /><br /><br /><br /><br /><br /><br /><?php//<!--$username = "";$pw1 = "";$pw = "";$bool[1]=true;$bool[2]=true;$bool[3]=true; // the booleans$bool[4]=true;$bool[5]=true;$bool[6]=true;function noerror() { $var131='<div style=\'Position: absolute; top: 104; left: 0;\'> <a href="Home.php"><img src="Home Button.gif" style="border: 0px;"></a> </div> <div style=\'Position: absolute; top: 144; left: 0;\'> <img src="BlackButton.gif" width="130" height="35"> </div> <div style=\'Position: absolute; top: 177; left: 0;\'> <a href="Story.php"><img src="Story Button.gif" style="border: 0px;"></a> </div> <div style=\'Position: absolute; top: 217; left: 0;\'> <img src="BlackButton.gif" width="130" height="35"> </div> <div style=\'Position: absolute; top: 250; left: 0;\'> <a href="Signup.php"><img src="Signup Button.gif" style="border: 0px;"></a> </div> <div style=\'Position: absolute; top: 290; left: 0;\'> <img src="BlackButton.gif" width="130" height="35"> </div> <div style=\'Position: absolute; top: 323; left: 0;\'> <a href=""><img src="Forum Button.gif" style="border: 0px;"></a> </div> <div style=\'Position: absolute; top: 363; left: 0;\'> <img src="BlackButton.gif" width="130" height="35"> </div> <div style=\'Position: absolute; top: 397; left: 0;\'> <a href="contact us.php"><img src="contact us.gif" style="border: 0px;"></a> </div> <div style=\'Position: absolute; top: 437; left: 0;\'> <img src="BlackButton.gif" width="130" height="35"> </div> <div style=\'Position: absolute; top: 470; left: 0;\'> <a href=""><img src="membership button.gif" width=\'130\' style="border: 0px;"></a> </div>'; echo $var131; }$st='</div> <div align=\'center\'>';echo $st;$username = (isset($_POST['username']));$pw1 = (isset($_POST['password1']));$pw2 = (isset($_POST['password2']));$em1 = (isset($_POST['email1'])); // the emails, usernames, passwords, and if t&c (terms and conditions)$em2 = (isset($_POST['email2']));// box was checked$tc=(isset($_POST['t&c']));if (strlen($username) < 5) { $bool[1]=false; echo '<font color="blue" size="4">Error:</font><font color="blue" size="3"><i> Your username must be no less then 5 characters long.<br /></i></font>'; }if (strlen($pw1) < 5) { $bool[2]=false; echo '<font color="blue" size="4">Error:</font><font color="blue" size="3"><i> Your password must be no less then 5 characters long.<br /></i></font>'; }if (strlen($pw2) < 5) { $bool[3]=false; echo '<font color="blue" size="4">Error:</font><font color="blue" size="3"><i> Your confirm password must be no less then 5 characters long.<br /></i></font>'; }if ($em1!==$em2) { echo '<font color="blue" size="4">Error:</font><font color="blue" size="3"><i> Your e-mail\'s do not match.<br /></i></font>'; $bool[4]=false; }if ($pw1 !== $pw2) { echo '<font color="blue" size="4">Error:</font><font color="blue" size="3"><i> Your passwords do not match.<br /></i></font>'; $bool[5]=false; }if ($tc == "on") { echo '<font color="blue" size="4">Error:</font><font color="blue" size="3"><i> Please check the terms & conditions box.<br /></i></font>'; $bool[6]=false; }$i=0;for ( $i = 1; $i < 7; $i++) { if (!$bool[$i]) { $i=20; $var2="<div align='center'><input type='button' value='Return' onClick='history.go(-1)'></div>"; echo $var2; } }if ($bool[1] == true && $bool[2] == true && $bool[3] == true && $bool[4] == true && $bool[5] == true && $bool[6] == true) { $con=mysql_connect("localhost","mythicae_MythicA","rainmaker"); if (!$con) { die("Poo ".mysql_error()); } $username=(isset($_POST['username'])); $password1=(isset($_POST['password1'])); $email1=(isset($_POST['email1'])); mysql_select_db("mythicae_chars", $con)or die("Mailed ".mysql_error()); mysql_query("INSERT INTO `users` SET `username` = '$username', `userpass` = '$password1', `email` = '$email1'"); $inv = array("Iron Dagger", "Ignite"); $inv=serialize($inv); $tcn=$username; mysql_query("INSERT INTO chars SET `mlvl` = 1, `charname` = '$tcn', `strlvl` = 1, `strdmg` = 0, `strxp` = 0, `strdiv` = 1, `dexlvl` = 1, `dexcth` = 0, `dexxp` = 0, `dexdiv` = 1, `currlife` = 20, `maxlife` = 20, `deflvl` = 1, `defxp` = 0, `defda` = 0, `defdiv` = 1, `intlvl` = 1, `intxp` = 0, `intdiv` = 1, `foclvl` = 1, `focxp` = 0, `focdiv` = 1, `mag` = 10, `weapon` = 'Iron Dagger', `spell` = 'Ignite', `gold` = 0, `bankedgold` = 10, `phd` = 0, `sa` = 1, `tstr` = 1, `tdex` = 0, `tdef` = 0, `tint` = 0, `tfoc` = 0, `currmonster` = 0, `magmax` = 10, `helm` = 'None', `bp` = 'None', `lp` = 'None', `shield` = 'None', `boots` = 'None', `amulet` = 'None', `ring` = 'None', `misc` = 'None', `wdmg` = 0, `vert` = 0, `horz` = 0, `currtown` = 'Open Plains', `inv` = '$inv' `equipment` = 0, `wisq` = 0, `belt` = 'None', `currlifemon` = 0, `currmaxlifemon` = 0, `dse` = 0, `lastfight` 0"); $msg='<font color="darkred" size="4">Welcome to Mythic Aeons</font>'; $subject='Activation Code'; $from='[email protected]'; $headers='From: '.$from; mail($email1,$subject,$msg,$headers); mysql_close($con); }//-->/*noerror();echo "<font color='blue' size='4'>Welcome to Mythic Aeons <br /></b><i>Please go to your e-mail and follow the instructions on the e-mail to activate your account</i></font>"; $var47="<div align='center'><input type='button' value='Continue to login' onClick=\"location='Home.php'\"></div>";echo $var47;*/?></div></div></body></html>[/code]Thanks Link to comment https://forums.phpfreaks.com/topic/33714-if-strlenusername-5-not-working-and-more-problems-like-this/ Share on other sites More sharing options...
play_ Posted January 11, 2007 Share Posted January 11, 2007 You need to create the bool array first.$username = (isset($_POST['username'])); ----> this will either give you 0 or 1. so it'll always be less than 5 Link to comment https://forums.phpfreaks.com/topic/33714-if-strlenusername-5-not-working-and-more-problems-like-this/#findComment-158090 Share on other sites More sharing options...
play_ Posted January 11, 2007 Share Posted January 11, 2007 [quote author=play_ link=topic=121906.msg502082#msg502082 date=1168504758]$username = (isset($_POST['username'])); ----> this will either give you 0 or 1. so it'll always be less than 5[/quote]That goes for all these:$pw1 = (isset($_POST['password1']));$pw2 = (isset($_POST['password2']));$em1 = (isset($_POST['email1'])); $em2 = (isset($_POST['email2'])); Link to comment https://forums.phpfreaks.com/topic/33714-if-strlenusername-5-not-working-and-more-problems-like-this/#findComment-158091 Share on other sites More sharing options...
Mythic Fr0st Posted January 12, 2007 Author Share Posted January 12, 2007 hmmBut if I do$username = $_POST['username'] I get the error"Undefined index 'username'"and, if I also had the problem doing it like thisif (isset($_POST['username'])) { $username=$_POST['username']; }still was always less than 5, but thanks I see why thats happen, any idea's how to fix it Link to comment https://forums.phpfreaks.com/topic/33714-if-strlenusername-5-not-working-and-more-problems-like-this/#findComment-158849 Share on other sites More sharing options...
DarkendSoul Posted January 12, 2007 Share Posted January 12, 2007 Are you looking at this page with out posting? This includes when you did have the [quote]$username = $_POST['username'] I get the error"Undefined index 'username'"[/quote] Notice... Also I'm pretty sure "Undefined index '*'" are notices not errors and will not change how your script is run. Try changing your php.ini. The normal, best way to have the set up is[quote]error_reporting = E_ALL & ~E_NOTICE[/quote]E_NOTICE is so annoying, it displays notices for everything.I would recommend that you do have notices logged though. In case there is a time that you need to know something like this. :) Link to comment https://forums.phpfreaks.com/topic/33714-if-strlenusername-5-not-working-and-more-problems-like-this/#findComment-158853 Share on other sites More sharing options...
btherl Posted January 12, 2007 Share Posted January 12, 2007 This code you have in your last post is correct:[code=php:0]if (isset($_POST['username'])) { $username=$_POST['username']; }[/code]Then strlen($username) will only be less than 5 if the username really is less than 5 characters long. Link to comment https://forums.phpfreaks.com/topic/33714-if-strlenusername-5-not-working-and-more-problems-like-this/#findComment-158856 Share on other sites More sharing options...
Mythic Fr0st Posted January 13, 2007 Author Share Posted January 13, 2007 well, the code I had didnt work...error_reporting = E_ALL & ~E_NOTICEHow do I log the NOTICES? Link to comment https://forums.phpfreaks.com/topic/33714-if-strlenusername-5-not-working-and-more-problems-like-this/#findComment-159707 Share on other sites More sharing options...
Mythic Fr0st Posted January 13, 2007 Author Share Posted January 13, 2007 Well... sorry to double post[code]if (isset($_POST['username'])) { $username = $_POST['username']; if (strlen($username) < 5) { $bool[1]=false; echo '<font color="blue" size="4">Error:</font><font color="blue" size="3"><i> Your username must be no less then 5 characters long.<br /></i></font>'; } }[/code]is the code I used on username, and it just stopped appearing all together...alsocheck out the problem at www.mythicaeons.comgo to signup, and then click the "SIGNUP" button on the page, you'll see Link to comment https://forums.phpfreaks.com/topic/33714-if-strlenusername-5-not-working-and-more-problems-like-this/#findComment-159741 Share on other sites More sharing options...
play_ Posted January 13, 2007 Share Posted January 13, 2007 Mythic, this isn't hard script to write, and it seems like you are coding an online-based word game.If you're having trouble with the sign up form, you'll surely have trouble coding your game.Perhaps you should buy a php book and read it from first to last page. even if the material isn't related to what you are doing....it will give you a huge jumpstart Link to comment https://forums.phpfreaks.com/topic/33714-if-strlenusername-5-not-working-and-more-problems-like-this/#findComment-159803 Share on other sites More sharing options...
Eugene Posted January 13, 2007 Share Posted January 13, 2007 [code=php:0]<?PHP$username = (isset($_POST['username'])) ? $_POST['username'] : '';$pw1 = (isset($_POST['password1'])) ? $_POST['password1'] : '';$pw2 = (isset($_POST['password2'])) ? $_POST['password2'] : '';$em1 = (isset($_POST['email1'])) ? $_POST['email1'] : ''; $em2 = (isset($_POST['email2'])) ? $_POST['email2'] : '';?>[/code]Is equivalent to writing:[code=php:0]<?PHPif(isset($_POST['username'])) { $username = $_POST['username'];}else { $username = '';}?>[/code]I hope that helps. Link to comment https://forums.phpfreaks.com/topic/33714-if-strlenusername-5-not-working-and-more-problems-like-this/#findComment-159806 Share on other sites More sharing options...
Mythic Fr0st Posted January 13, 2007 Author Share Posted January 13, 2007 Techniquely play, I got it working, then somehow it got messed up... and my game is text based RPG and im going fine with it ^_^, forms are just a pain Link to comment https://forums.phpfreaks.com/topic/33714-if-strlenusername-5-not-working-and-more-problems-like-this/#findComment-159833 Share on other sites More sharing options...
Mythic Fr0st Posted January 13, 2007 Author Share Posted January 13, 2007 and thanks G_F_DHow come I cant edit posts, am I missing the option somewhere or something? Link to comment https://forums.phpfreaks.com/topic/33714-if-strlenusername-5-not-working-and-more-problems-like-this/#findComment-159865 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.