Jump to content

boblan66

Members
  • Posts

    36
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

boblan66's Achievements

Member

Member (2/5)

0

Reputation

  1. Thank you for your quick response. You validified my thinking.
  2. I am creating a membership site for my wife's high school class. This code was part of an example for checking if the username and password was valid.
  3. I would like to know if I'm thinking in the right direction? I recently was looking at sample code that gave this as an example: $sql_email_check = mysql_query("SELECT email_address FROM users WHERE email_address='$email_address'"); $sql_username_check = mysql_query("SELECT username FROM users WHERE username='$username'"); If I learned correctly while reading about SQL, the two lines of code could have been one. Such as: $sql_email_check = mysql_query("SELECT email_address FROM users WHERE email_address='$email_address' AND username='$username'"); Is this correct?
  4. The code seems to cear debug until I attempt to exit after doing a while loop. PHP Parse error: syntax error, unexpected T_ELSE in C:\Users\Bob\Desktop\TAFT WEB\test\login.php on line 46 Here's the code: <?php /* -----------------------NOVEMBER 2010-------------------- */ // User has 3 trys to enter correct username and password // increment by one $num_log = ($num_logs + 1); if ($_POST['username']) { //Connect to the database through our include include_once "connect_to_mysql.php"; $username = stripslashes($_POST['username']); $username = strip_tags($username); $username = mysql_real_escape_string($username); $password = ereg_replace("[^A-Za-z0-9]", "", $_POST['password']); // filter everything but numbers and letters $password = md5($password); } // Make query and then register all database data that - // cannot be changed by member into SESSION variables. // Data that you want member to be able to change - // should never be set into a SESSION variable. $sql = mysql_query("SELECT * FROM register WHERE username='$username' AND password='$password'"); $login_check = mysql_num_rows($sql); if($login_check > 0); { while($row = mysql_fetch_array($sql)){ // Get member ID into a session variable $id = $row["id"]; session_register('id'); $_SESSION['id'] = $id; // Get member username into a session variable $username = $row["username"]; session_register('username'); $_SESSION['username'] = $username; // Update last_log_date field for this member now mysql_query("UPDATE user_log SET log_on=now() WHERE id='$id'"); // Print success message here if all went well then exit the script header("location: memPage.shtml php?id=$id"); exit(); } // close while ERROR ---> else { exit() } // Print login failure message to the user and link them back to your login page print '<br><br> <font color="#FF0000"> No match was found in our member records, try again. </font> <br><br> <a href="login.php">Click here</a> to go back to the login page.'; exit(); // close if post ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Login to your profile</title> <script type="text/javascript"> <!-- Form Validation --> function validate_form ( ) { valid = true; if ( document.logform.email.value == "" ) { alert ( "Please enter your User Name" ); valid = false; } if ( document.logform.pass.value == "" ) { alert ( "Please enter your password" ); valid = false; } return valid; } <!-- Form Validation --> </script> </head> <body> <div align="center"> <h3 style="test-align:center;font-weight:bold; color:blue;padding-top:25px;padding-bottom;15px;"> Log in to your account here </h3> </div> <table align="center" cellpadding="5"> <form action="login.php" method="post" enctype="multipart/form-data" name="logform" id="logform" onsubmit="return validate_form ( );"> <tr> <td class="style7"><div align="right">Username:</div></td> <td><input name="username" type="varchar" id="username" size="30" maxlength="50" /></td> </tr> <tr> <td class="style7"><div align="right">Password:</div></td> <td><input name="password" type="password" id="password" size="50" maxlength="24" /></td> </tr> <tr> <td> </td> <td><input name="Submit" type="submit" value="Login" /></td> </tr> </form> </table> </body> </html>
  5. Yes, I must be slow. I have read and reread the section on controls, If's , loops etc. I think I got it, go to the code I sent as a attachment and still get the error. I somewhat embarrassed to ask for more help. I thought I'd go to another forum and ask. But I like this one. I know once I get one working correctly, I could build upon it. I look at the code and based upon what I think I'm reading, I figure I got it down, only to have that error show up again on the same line. At least I know that I'm missing a } or smi-colon. But where? Fully [attachment deleted by admin]
  6. Dan, Thanks for the lesson. I appreciate that you took the time. Bob...
  7. I read the manual. However If you read my previous posts, the one reason I'm having so much trouble is that I have bad vision. Butr I did read the link you provided.
  8. I located the h1, and corrected it to read h1 {. line 140 is html and should not need closing }. I also fixed the missing } in that css element. I think I understand the use of {} Tell me if I'm correct! It signifies the start and end of a operation. What I'm confused with is the If else if and else. for example, $user1 = $name; if $user == !$user1; { echo "You are not Johm Smith!"; else if $user == $user1; ##Now do I place a { here, and if so after the next echo or just after the else statment? echo "Good Day John"; } Else $msg = "I do not know who you are. Get busy and learn this stuff!" echo $msg; } Is this correct use of ; and curly brackets? Maybe I'll get this through my thick head once and for all.
  9. Thank you very much for your assistance. Again something simple to fix. I really appreciate your help. Bob
  10. I just finished a page of code that passes all the debug tests except for the very last line on the page. </html>. The page has php and html, java script and some SQL. (see I'm learning and hadn't placed a post until I exhausted my limited resources. The Error Codeis: PHP Parse error: syntax error, unexpected $end in C:\wamp\www\registerform.php on line 292 Here's my concern: I read this error statement as an error()is missing. Please clarify something for me, You start the php code with <?php and end it with ?>. I also understand that the end() will stop all further operation. Correct. When you have a form call itself for data checking, and if the data is correct, send it to the appropriate database table, does one need to place the end() at the end of the php portion of the code? And if so, will it not stop any of the code from being read the first time the page is called? Also since the FORMs action calls for the page to load itself for data verification, how at the end of the checking do I go call another page? here's the page: The page is attached: [attachment deleted by admin]
  11. ManiacDan; I pasted the code on my form and made mods to the referencing the form name etc. However I came up with some interesting problems, when I ran the form. I attached the form to this reply for your review. Here are my questions: 1. I noticed that the script was placed directly after the closing form tag, so that's where I placed it in my form. Correct? 2. The radio buttons will not change state. If I select male and decide to change it to female, both buttons are selected. You can't select one. This is the same for any input field that has a radio button, not just the sex buttons. I tried renaming the test file that I'm using to madian_name.html and it changes to: madian_name.html.txt. is this something to do with javascript? I really appreciate your assistance. Believe it or not, I'm learning something. [attachment deleted by admin]
  12. Thank you very much for your example. I'm going to try it right now. I learn better by example. Always have. Again thanks.
  13. Ok I broke out the books on javascript and found a little help on the issue. !. I wish the new field to appear when the user clicks on the Female radio button. Not after the submit button is clicked, 2. How does one capture the button being clicked? 3. The javascript code below gives me the same results as with the previous php. <doctype html> <html> <body> <label>Male: </label><input type="radio" name="sex" value=1><label>Male</label> <label>Female: </label><input type="radio" name="sex" value=2><label>Female</label> <script type="text/javascript"> <!-- var result = value; if(result == 2){ document.write("<label>Madian Name: </label><input type="madianname" name="sex" size="14" autofocus>"); } //--> </script> <br> <label>City:</label><input type="varchar" id="city" placeholder="City" size="14"> <br><br> <input type="submit" value="GO"> </form> </body> </html>
  14. Javascript -- Well that's something else I need to learn. Can you provide an example for me that would address this issue. I guess I'm getting a good learning experience out of this!
  15. when in a form, I wish to build a conditional that if the response to a radio button is a value of 2 (female), it will display an input requesting for users maiden name. If not 2 goes to the next input statement. Here is code I was experimenting with: <html> <body> <form action="" name="test" method='POST'> <input type="radio" id="sex" value=1 checked><label>Male</label> <input type="radio" id="sex" value=2><label>Femaleale</label> <?php $result = "value"; if ($result == 2) echo "<input type='int' id='gradYear' size='3' required>"; else echo "Not a female!" ?> <input type="submit" value="GO"> </form> </body> </html> The code passes debug, however, Not a Female is displayed. My question is - Can I do this and if so, what value do I test against id='sex' or value. I tried each one but gave the same results. I realize that $_POST[sex] would be used after the submit button is clicked. But this has me stumped. Thanks for the assis in advance.
×
×
  • 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.