Jump to content

BrettHartel

Members
  • Posts

    54
  • Joined

  • Last visited

Everything posted by BrettHartel

  1. I was wrong, adding that string made ALL passwords and no password work to log-in
  2. Figured it out, I needed to call the $_Post[Password] with the mysql_real_escape_strin!
  3. Thank you for taking the time to help me I am trying to hashtag passwords and I was finally able to get the created accounts to work. But, when I try to log-in, the hashtag is different from the original hashtag. What am I do wrong? Sign-Up Code $password = "$_POST[Password]"; $Blowfish_Pre = '$2a$05$'; $Blowfish_End = '$'; $Allowed_Chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789./'; $Chars_Len = 63; $Salt_Length = 21; for($i=0; $i<$Salt_Length; $i++) { $salt .= $Allowed_Chars[mt_rand(0,$Chars_Len)]; } $bcrypt_salt = $Blowfish_Pre . $salt . $Blowfish_End; $hashed_password = crypt($password, $bcrypt_salt); $sql="INSERT INTO Salt (User_ID, Salt) VALUES ('$User_ID','$salt')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } Log-in Code $Blowfish_Pre = '$2a$05$'; $Blowfish_End = '$'; $Entered_Password = $_Post[Password]; $Result_Salt = mysql_query("SELECT Salt FROM Salt WHERE User_ID='$User_ID'"); while ($row = mysql_fetch_assoc($Result_Salt)) { $User_Salt = $row[salt]; } $bcrypt_salt = $Blowfish_Pre . $User_Salt . $Blowfish_End; $Hashed_Password = crypt($Entered_Password, $bcrypt_salt); Sincerely, Brett Hartel
  4. I was missing this: <meta http-equiv="x-ua-compatible" content="ie=edge"/>
  5. When I try to move the <div> with top:0px; or left:0px; or try using top:20%; or left:20%; nothing is happening to my <div>. It is not even being fixed. It just gets lined in a row with the rest of the code. What am I doing wrong? My file is menu.php <?php header("Content-type: text/css; charset: UTF-8;"); $ColorMain1="#227D4C"; $ColorMain1Dark="#092315"; $ColorMain2="#7D2252"; $ColorMain2Dark="#220916"; ?> <div id="mainpagewidth" style="position:fixed;left:0px;top:0px;width:1024px;background-color:#000000;"> Hello <?php if (isset($_COOKIE[user_ID])) echo "Welcome " . $_COOKIE[user_ID] . "!<br>"; else { ?> <div id="newuser" style="position:fixed;left:20px;background-color:#FEEC65;width:540px;"> <table border="4px" bordercolor="#220916" width="540px"><tr><td width="50%"> <div style="background-color:#220916;height:1px;width:100%x;font-size:1px;"></div> <div style="font-size:25PX;text-align:center;background-color:#227d4c;color:#220916">Log-In</div> <div style="background-color:#220916;height:1px;width:100%;font-size:1px;"></div><br /> <form action="login.php" method="post"> <div style="text-align:right;line-height:25px;">e-Mail: <input type="text" name="eMail" style="width=152px;"> <br /> Password: <input type="password" name="Password" style="width=152px;"> <br /><br /> <input type="submit" value="Log In"> <br /></div> </td><td width="50%"><br /> <div style="text-align:center;"><font style="font-size:25px;">Sign Up</font><br /> <font style="font-size:50px;">It's FREE!</font></div> <div style="text-align:right;line-height:25px;"><form action="signup.php" method="post"><br /> e-Mail: <input type="text" name="eMail" style="width=152px;"> <br /> First Name: <input type="text" name="FirstName" style="width=152px;"> <br /> Last Name: <input type="text" name="LastName" style="width=152px;"> <br /> Password: <input type="password" name="Password" style="width=152px;"> <br /> <input type="radio" name="Gender" value="male">Male <input type="radio" name="Gender" value="female">Female <br /> Birthday: <select name="Month"> <option value="1" selected="selected">Jan</option> <option value="2">Feb</option> <option value="3">Mar</option> <option value="4">Apr</option> <option value="5">May</option> <option value="6">Jun</option> <option value="7">Jul</option> <option value="8">Aug</option> <option value="9">Sep</option> <option value="10">Oct</option> <option value="11">Nov</option> <option value="12">Dec</option> </select> <select name="Day"> <option value="1" selected="selected">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">20</option> <option value="21">21</option> <option value="22">22</option> <option value="23">23</option> <option value="24">24</option> <option value="25">25</option> <option value="26">26</option> <option value="27">27</option> <option value="28">28</option> <option value="29">29</option> <option value="30">30</option> </select> <input type="text" name="Year" size="4" maxlength="4" onkeypress='validate(event)' > <br /><br /> <input type="submit" value="Sign Up"> </form></div><br /> </td></tr></table> </div> <?php ;} ?> </div> <script> function validate(evt) { var theEvent = evt || window.event; var key = theEvent.keyCode || theEvent.which; key = String.fromCharCode( key ); var regex = /[0-9]|\./; if( !regex.test(key) ) { theEvent.returnValue = false; if(theEvent.preventDefault) theEvent.preventDefault(); } } </script>
  6. Each of my webpages use the include file for a menu that I can easily maintain. I want to include a css.style link with my menu. Will that work properly or should I echo and print it in the menu.php If anyone has a link to a tutorial on this I would love for you to post it!
  7. My php script creates an array of cookies. I know this because I print them on the screen. Unfortunately, when I click on a different page the cookies are not registering. I try to print the array and nothings shows. I do not get any errors. What should I do? Index <!DOCTYPE html> <html> <head> <title>Diamond Book Club</title> </head> <body> <!--#include virtual="menu.html" --> <p style="text-align:center;color:red;"><b>Do not attempt to utilize this site. Your browser may crash and you may experience unplanned credit card charges! This site is still being tested for usability.</b></p> <form action="signup.php" method="post"> eMail: <input type="text" name="eMail"> First Name: <input type="text" name="FirstName"> Last Name: <input type="text" name="LastName"> Password: <input type="password" name="Password"> <input type="radio" name="Gender" value="male">Male <input type="radio" name="Gender" value="female">Female Birth Month: <input type="text" name="Month"> Birth Day: <input type="text" name="Day"> Birth Year: <input type="text" name="Year"> <input type="submit" value="Sign Up"> </form> <p> <form action="deleteaccount.php" method="post"> User ID: <input type="text" name="User_ID"> <input type="submit" value="Delete User ID"> </form> <p> <?php if (isset($_COOKIE["User_ID"])) echo "Welcome " . $_COOKIE["User_ID"] . "!<br>"; else echo "Welcome guest!<br>"; ?> </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> <p> Text from Index </p> </div> </div> </body> </html> The Menu: <style> a.menu {font-size:42px} a.menu:link {color:#306754;text-decoration:none;} a.menu:visited {color:#306754;text-decoration:none;} a.menu:hover {color:#B5EAAA;text-decoration:none;} a.menu:active {color:#306754;text-decoration:none;} div.divMenu { float:left;width:35px;height35px; } a.menublank0 { display:inline-block; /* This cover full td */ height:50px; width:12px; } a.menublank1 { display:inline-block; /* This cover full td */ height:35px; width:70.9px; } a.home { display:inline-block; /* This cover full td */ background:url('/images/menubuttons.gif') no-repeat 0px 0px ; /*sets the background link image */ height:35px; width:35px; } a.home:hover { background:url('/images/menubuttons.gif') no-repeat 0px -35px ; /*sets the background link image and pushes the rest state up above view */ } a.profile { display:inline-block; /* This cover full td */ background:url('/images/menubuttons.gif') no-repeat -35px 0px ; /*sets the background link image */ height:35px; width:35px; } a.profile:hover { background:url('/images/menubuttons.gif') no-repeat -35px -35px ; /*sets the background link image and pushes the rest state up above view */ } a.mail { display:inline-block; /* This cover full td */ background:url('/images/menubuttons.gif') no-repeat -70px 0px ; /*sets the background link image */ height:35px; width:35px; } a.mail:hover { background:url('/images/menubuttons.gif') no-repeat -70px -35px ; /*sets the background link image and pushes the rest state up above view */ } a.shop { display:inline-block; /* This cover full td */ background:url('/images/menubuttons.gif') no-repeat -105px 0px ; /*sets the background link image */ height:35px; width:35px; } a.shop:hover { background:url('/images/menubuttons.gif') no-repeat -105px -35px ; /*sets the background link image and pushes the rest state up above view */ } a.buddy { display:inline-block; /* This cover full td */ background:url('/images/menubuttons.gif') no-repeat -140px 0px ; /*sets the background link image */ height:35px; width:35px; } a.buddy:hover { background:url('/images/menubuttons.gif') no-repeat -140px -35px ; /*sets the background link image and pushes the rest state up above view */ } a.chat { display:inline-block; /* This cover full td */ background:url('/images/menubuttons.gif') no-repeat -175px 0px ; /*sets the background link image */ height:35px; width:35px; } a.chat:hover { background:url('/images/menubuttons.gif') no-repeat -175px -35px ; /*sets the background link image and pushes the rest state up above view */ } a.author { display:inline-block; /* This cover full td */ background:url('/images/menubuttons.gif') no-repeat -210px 0px ; /*sets the background link image */ height:35px; width:35px; } a.author:hover { background:url('/images/menubuttons.gif') no-repeat -210px -35px ; /*sets the background link image and pushes the rest state up above view */ } a.search { display:inline-block; /* This cover full td */ background:url('/images/menubuttons.gif') no-repeat -245px 0px ; /*sets the background link image */ height:35px; width:35px; } a.search:hover { background:url('/images/menubuttons.gif') no-repeat -245px -35px ; /*sets the background link image and pushes the rest state up above view */ } a.help { display:inline-block; /* This cover full td */ background:url('/images/menubuttons.gif') no-repeat -280px 0px ; /*sets the background link image */ height:35px; width:35px; } a.help:hover { background:url('/images/menubuttons.gif') no-repeat -280px -35px ; /*sets the background link image and pushes the rest state up above view */ } </style> <?php if (isset($_COOKIE["User_ID"])) echo "Welcome " . $_COOKIE["User_ID"] . "!<br>"; else { ?> <div id="newuser" style="position:fixed;top:25%;left:20%;background-color:#FEEC65;"> <table border="4px" bordercolor="#220916"><tr><td width="50%"> <div style="background-color:#220916;height:1px;width:100%;"></div> <div style="font-size:25PX;text-align:center;background-color:#227d4c;color:#220916">Log-In</div> <div style="background-color:#220916;height:1px;width:100%;"></div><br /> <form action="login.php" method="post"> <div style="text-align:right;line-height:25px;">e-Mail: <input type="text" name="eMail"> <br /> Password: <input type="password" name="Password"> <br /><br /> <input type="submit" value="Log In"> <br /></div> </td><td width="50%"><br /> <div style="text-align:center;"><font style="font-size:25px;">Sign Up</font><br /> <font style="font-size:50px;">It's FREE!</font></div> <div style="text-align:right;line-height:25px;"><form action="signup.php" method="post"><br /> e-Mail: <input type="text" name="eMail"> <br /> First Name: <input type="text" name="FirstName"> <br /> Last Name: <input type="text" name="LastName"> <br /> Password: <input type="password" name="Password"> <br /> <input type="radio" name="Gender" value="male">Male <input type="radio" name="Gender" value="female">Female <br /> Birth Mon: <input type="text" name="Month"> <br /> Birth Day: <input type="text" name="Day"> <br /> Birth Year: <input type="text" name="Year"> <br /><br /> <input type="submit" value="Sign Up"> </form></div><br /> </td></tr></table> </div> <?php ;} ?> <div id="divPreHeader" style="position:fixed;width:1024px;height:12px;left:0px;top:0px;background-color:#FFFFFF;"> </div> <div id="divHeader" style="position:fixed;width:1024px;height:50px;left:0px;top:12px;background-color:#FFFFFF;"> <a class="menublank0"></a> <img src="images/header.gif" border=0 alt="Diamond Book Club" /> </div> <div id="divPreMenu0" style="position:fixed;left:0px;top:62px;width:1024px;height:12px;background-color:#FFFFFF;"> </div> <div id="divPreMenu1" style="position:fixed;width:1024px;height:3px;top:74px;left:0;background-color:#092315;"> </div> <div id="divPreMenu2" style="position:fixed;width:1024px;height:1px;top:77px;left:0;background-color:#220916;"> </div> <div id="divMenu" style="position:fixed;width:1024px;height:35px;top:78px;left:0;background-color:#227d4c;"> <a class="menublank1"></a> <a class="home" href="/"></a> <a class="menublank1"></a> <a class="profile" href="/database_profile"></a> <a class="menublank1"></a> <a class="mail" href="/database_mail"></a> <a class="menublank1"></a> <a class="shop" href="/database_shop"></a> <a class="menublank1"></a> <a class="buddy" href="/database_buddy"></a> <a class="menublank1"></a> <a class="chat" href="/database_chat"></a> <a class="menublank1"></a> <a class="author" href="/database_author"></a> <a class="menublank1"></a> <a class="search" href="/database_search"></a> <a class="menublank1"></a> <a class="help" style="text-align:right;" href="/database_help"></a> <a class="menublank1"></a> </div> <div id="divPostMenu1" style="position:fixed;width:1024px;height:1px;top:113px;left:0;background-color:#220916;"> </div> <div id="divPreSubMenu0" style="position:fixed;left:12px;top:114px;width:3px;height:100%;background-color:#220916;"> </div> <div id="divPreSubMenu1" style="position:fixed;left:15px;top:114px;width:1px;height:100%;background-color:#227d4c;"> </div> <div id="divSubMenu" style="position:fixed;left:16px;top:114px;width:35px;height:100%;background-color:#7D2252;"> </div> <div id="divPostSubMenu1" style="position:fixed;left:51px;top:114px;width:1px;height:100%;background-color:#092315;"> </div> <div id="divMain" style="width:1024px;"> <div id="divPreContent" style="width:960px;height:114px;float:right;""> </div> <div id="divContent" style="width:960px;float:right;background-color:white;"> Setting Cookies after Sign Up (I removed all the echo with comment marts to prevent html from forming. It works and generates the array of cookies that should be created.) <?php $con = mysql_connect("localhost","****","****"); if (!$con){ die('Could not connect: . mysql_error()'); } mysql_select_db("****", $con); /* echo "Connected to: " . $con; */ $eMail="$_POST[eMail]"; /* echo "<br>My eMail: " . $eMail; */ $eMailResult = mysql_query("SELECT * FROM eMail WHERE eMail='$eMail'"); if (mysql_num_rows($eMailResult) == 0){ /* echo "<br>My eMail is Unique"; */} else { /* echo "<br><b>eMail is already being used.</b> Request your password or choose a different eMail. "; */ exit(0);} $User_Movement=rand(0,9999); do { $User_ID=rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9); $User_IDResult = mysql_query("SELECT * FROM eMail WHERE User_ID='$User_ID'");} while (mysql_num_rows($User_IDResult) != 0); /* echo "<br>User ID: " . $User_ID; echo "<br>User ID is Unique"; */ $sql="INSERT INTO eMail (User_ID, eMail) VALUES ('$User_ID','$_POST[eMail]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } /* echo "<br>eMail Added"; */ $sql="INSERT INTO FirstName (User_ID, FirstName) VALUES ('$User_ID','$_POST[FirstName]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } /* echo "<br>First Name added"; */ $sql="INSERT INTO LastName (User_ID, LastName) VALUES ('$User_ID','$_POST[LastName]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } /* echo "<br>Last Name added"; */ $sql="INSERT INTO Gender (User_ID, Gender) VALUES ('$User_ID','$_POST[Gender]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } /* echo "<br>Gender added"; */ $sql="INSERT INTO Password (User_ID, Password) VALUES ('$User_ID','$_POST[Password]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } /* echo "<br>Password added"; */ $sql="INSERT INTO Birthday (User_ID, Month, Day, Year) VALUES ('$User_ID','$_POST[Month]','$_POST[Day]','$_POST[Year]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } /* echo "<br>Birthday added"; */ $sql="INSERT INTO Movement (User_ID, User_Movement) VALUES ('$User_ID','$User_Movement')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } /* echo "<br>Movement added"; */ setcookie( "User_ID", $User_ID, time()+6000, "/", ".diamondbookclub.com" ); setcookie( "FirstName", $_POST['FirstName'], time()+6000, "/", ".diamondbookclub.com" ); setcookie( "LastName", $_POST['LastName'], time()+6000, "/", ".diamondbookclub.com" ); setcookie( "eMail", $_POST['eMail'], time()+6000, "/", ".diamondbookclub.com" ); setcookie( "Day", $_POST['Day'], time()+6000, "/", ".diamondbookclub.com" ); setcookie( "Month", $_POST['Month'], time()+6000, "/", ".diamondbookclub.com" ); setcookie( "Year", $_POST['Year'], time()+6000, "/", ".diamondbookclub.com" ); setcookie( "Gender", $_POST['Gender'], time()+6000, "/", ".diamondbookclub.com" ); print_r($_COOKIE); mysql_close($con); ?>
  8. Oh, i took the ) after the 60 away and it sent. Now I get this error and Im not sure how to fix it before the header since i don't include a header in my .php file. Warning: Cannot modify header information - headers already sent by (output started at /home/***:5) in /home/*** on line 90 Warning: Cannot modify header information - headers already sent by (output started at /home/***:5) in /home/*** on line 91 Warning: Cannot modify header information - headers already sent by (output started at /home/***:5) in /home/*** on line 92 Warning: Cannot modify header information - headers already sent by (output started at /home/***:5) in /home/*** on line 93 Warning: Cannot modify header information - headers already sent by (output started at /home/***:5) in /home/*** on line 94 Warning: Cannot modify header information - headers already sent by (output started at /home/***:5) in /home/*** on line 95 Warning: Cannot modify header information - headers already sent by (output started at /home/***:5) in /home/*** on line 96 Warning: Cannot modify header information - headers already sent by (output started at /home/***:5) in /home/*** on line 97 Array ( [s_pers] => s_lv=1354518011413|1449126011413; s_lv_s=First%20Visit|1354519811413; )
  9. I added the quote to the array keys but I know know what you mean by an extra ), I am not seeing it. Besides for the quote i cannot see a difference between what you and I wrote. I get the same error message after updating the quote. I now have this: setcookie( "User_ID", $User_ID, time()+60), "/", "***.com" ); setcookie( "FirstName", $_POST['FirstName'], time()+60), "/", "***.com" ); setcookie( "LastName", $_POST['LastName'], time()+60), "/", "***.com" ); setcookie( "eMail", $_POST['eMail'], time()+60), "/", "***.com" ); setcookie( "Day", $_POST['Day'], time()+60), "/", "***.com" ); setcookie( "Month", $_POST['Month'], time()+60), "/", "***.com" ); setcookie( "Year", $_POST['Year'], time()+60), "/", "***.com" ); Did you mean: setcookie( "FirstName", $_POST['FirstName'], time()+60, "/", "***.com" ); ? subtract the ) after the 60.
  10. Thank you for taking the time to help me. I keep getting the error: Parse error: syntax error, unexpected ',' in /home/*** on line 90 What did I do wrong? Here is my set cookie code which starts at line 90: setcookie( "User_ID", $User_ID, time()+60), "/", "***.com" ); setcookie( "FirstName", $_POST[FirstName], time()+60), "/", "***.com" ); setcookie( "LastName", $_POST[LastName], time()+60), "/", "***.com" ); setcookie( "eMail", $_POST[eMail], time()+60), "/", "***.com" ); setcookie( "Day", $_POST[Day], time()+60), "/", "***.com" ); setcookie( "Month", $_POST[Month], time()+60), "/", "***.com" ); setcookie( "Year", $_POST[Year], time()+60), "/", "***.com" ); Sincerely, Brett Hartel
  11. LOL! Sorry everyone. This wasn't php, it was javascript. I changed the cookie check to php and it is working now!
  12. There are two options. You could have them sign-up for your site to store the data in a database or create cookie that will last a certain amount of time (say a year). The database would be perminent while the cookie would be temporary. You should read the tiles of HTML, CSS, Javascript, PHP, and MYSQL at www.w3schools.com then come back here and ask questions so you understand the basics. That is how I started learning. I just finished setting up a database and now my site can let people sign-up and delete their accounts. Pretty basic stuff, but super fun to learn!
  13. Thank you for taking the time to help me! My "check for cookie" code doesn't work. It doesnt show any errors or do anything. Can someone help me understand what I am doing wrong. I am trying to create the code to check for a cookie. If it doesn't exist I want it to display a <div>information</div>. My code to check for a cookie is called usercheck_cookie.html Here is my code to check for a username: <script> function getCookie(c_name) { var i,x,y,ARRcookies=document.cookie.split(";"); for (i=0;i<ARRcookies.length;i++) { x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("=")); y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1); x=x.replace(/^\s+|\s+$/g,""); if (x==c_name) { return unescape(y); } } } function checkCookie() { var User_ID=getCookie("User_ID"); if (User_ID!=null && User_ID!="") { alert("Welcome again " + username); } else { alert("You are not a user!); echo "<html><div id="Signup" style="position:fixed;width:1000px;height:500px;top:300px;left:50%;background-color:#220916;"> </div></html>"; } } </script> Here is how I set it into my index.shtml: <!DOCTYPE html> <html> <head> <title>Diamond Book Club</title> <!--#include virtual="usercheck_cookie.html" --> </head> <body onload="checkCookie()"> // and the rest of my website is below Sincerely, Brett Hartel
  14. Thank you Muddy_Funster but I figured it out. I can use this: $User_ID=rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9).rand(0,9);
  15. How do you want to change them? I am confused. Can you offer more information.
  16. Thank you for taking the time to help me. I am trying to generate a string of sixteen characters that can look like 0000000000000000 to 9999999999999999 and set it as the global variable of $User_ID Here is the part of the code I am having trouble with: function genRandomString() { global $User_ID; $length = 16; $characters = "0123456789"; for ($p = 0; $p < $length; $p++) { $User_ID .= $characters[mt_rand(0, strlen($characters))]; } } Here is my whole code: <?php $con = mysql_connect("localhost","******","******"); if (!$con){ die('Could not connect: . mysql_error()'); } mysql_select_db("******", $con); echo "Connected to: " . $con; $eMail="$_POST[eMail]";$User_ID=""; echo "<br>My eMail: " . $eMail; $eMailResult = mysql_query("SELECT * FROM eMail WHERE eMail='$eMail'"); if (mysql_num_rows($eMailResult) == 0){ echo "<br>eMail is Unique"; } else { echo "eMail is NOT Unique<br>";} function genRandomString() { global $User_ID; $length = 16; $characters = "0123456789"; for ($p = 0; $p < $length; $p++) { $User_ID .= $characters[mt_rand(0, strlen($characters))]; } } echo "<br>User ID: " . $User_ID; mysql_close($con); ?>
  17. LOL! That is my problem. I have no idea how to know what query is empty or the steps to figure it out.
  18. Sorry to confuse you SocialCloud. I am confused about why I keep receiving the error "Error: Query was empty". I am new to PHP and Im not sure where I went wrong. The four points were just to allow the reader to know what I was trying to do. For your comment about #3, is my code incorrect?
  19. Maybe requinix has a way of making your query faster by knowing the information. Requinix has helped me improve my code for eMail unique identification.
  20. Thank you for the help thus far everyone! I have updated my code with the help of reqinix. Now I have this error: Error: Query was empty Brief - I want the user to enter their eMail into the form and submit it to signup.php; the PHP file will do the following: Generate a random User_ID that is 16 characters long. Check the database to make sure the Unque_ID does not exist. If it does exists the script will generate another random User_ID and attempt again . If it does NOT exist the PHP script will continue. Check the database to make sure the eMail does not exists. If it does exists the fuction will not create a new account and displays "eMail already exists." If it does NOT exists then the script will continue. The PHP script will add the informtion to the table named "eMail" as a new entry. Here is the updated script with requinix's help: <?php $con = mysql_connect("localhost","******","******"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("diamon79_mysql", $con); function generateRandomString($Generate_ID = 16) { return substr(str_shuffle("01234567890123456789"), 0, $Generate_ID); } $searchquery = "SELECT * FROM eMail WHERE `User_ID` = '$Generate_ID'"; $searchresult = mysql_query($searchquery) or die(mysql_error()); if (mysql_num_rows($searchresult) == 0) { $User_Id = $Generate_ID; eMailCheck(); } // no rows found else { generateRandomString(); } function eMailCheck() { $eMail = "$_POST[eMail]"; return $eMail; } $searcheMailquery = "SELECT * FROM eMail WHERE `eMail` = '$eMail'"; $searcheMailresult = mysql_query($searcheMailquery) or die(mysql_error()); if (mysql_num_rows($searcheMailresult) == 0) { PostInformation(); } // no rows found else { echo "eMail already exists"; } function PostInformation() { $sql="INSERT INTO eMail (User_D, eMail) VALUES ('$User_ID','$_POST[eMail]')"; } if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "1 record added"; mysql_close($con); ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.