
boblan66
Members-
Posts
36 -
Joined
-
Last visited
Never
Everything posted by boblan66
-
Thank you for your quick response. You validified my thinking.
-
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.
-
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?
-
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>
-
Don't need a direct answer - just where to look for the error
boblan66 replied to boblan66's topic in PHP Coding Help
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] -
Dan, Thanks for the lesson. I appreciate that you took the time. Bob...
-
Don't need a direct answer - just where to look for the error
boblan66 replied to boblan66's topic in PHP Coding Help
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. -
Don't need a direct answer - just where to look for the error
boblan66 replied to boblan66's topic in PHP Coding Help
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. -
Don't need a direct answer - just where to look for the error
boblan66 replied to boblan66's topic in PHP Coding Help
Thank you very much for your assistance. Again something simple to fix. I really appreciate your help. Bob -
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]
-
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]
-
Practicing with IF statements to answer my own question - question
boblan66 replied to boblan66's topic in PHP Coding Help
Thank you very much for your example. I'm going to try it right now. I learn better by example. Always have. Again thanks. -
Practicing with IF statements to answer my own question - question
boblan66 replied to boblan66's topic in PHP Coding Help
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> -
Practicing with IF statements to answer my own question - question
boblan66 replied to boblan66's topic in PHP Coding Help
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! -
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.
-
This is my time introducing myself to the forum. Firstly, I'm retired from the military (Navy Seabees) and a Viet Nam Vet. After the military, I was hired by a computer company outside Boston, MA. Where I spent my time in traveling and traing users on our software thought the world. I lectured in the netherlands for a month on Computerized Project Management. I'm now semi retired and work for the San Bernardino Superintendent of Schools in there special education program. I work directly with severely disabled children ages 14 - 22 of age. Since I had a stroke 5 years ago, I'm quite handicapped myself. And really cant see very well these days because of a retna going bad. I just wanted to let you know about myself, as I do come up with some off the wall questions. Have a good Holiday Season... BobLan66
-
Parse error: syntax error, unexpected '}', expecting ',' or ';' in /home/taft65/public_html/registerform.php on line 123 I noticed that I placed the eoor arrow pointing at the incorrect line. Line 123 is the beginning of the if statement. Here is some more of the code: <label>Email Address: </label><input type="varchar" id=email" size="12" maxlenght="50" required> <label>Confirm Email: </label><input type="varchar" id="email2" size="12" maxlenght="50"> <br> <br> <label>Phone: </label><input type="varchar" id="phone" size="10" maxlenght="40"> <label>Cell Phone: </label><input type="varchar" id="phone" size="10" maxlenght="40"> <br> <br> <label>Are you or your spouse a Taft Class of 1965 alumni?</label> <input type="radio" id="alumni" value=1 checked><label>yes</label> <input type="radio" id="alumni" value=2><label>no</label> <br> <label>Are you a graduate of Taft Union High School?</label> <input type="radio" id="alumni" value=3><label>yes</label> <?php // If alumni is equal to 3 display the input field Line 127--->If ($ans == 3);{ Echo "<input type='int' id='gradClass' size='4' maxlenght='4' placeholder='1977'>" } ?> <br> <hr> <br> <span class="subheader">PRIVACY</span> <br> <input type="radio" id="privacy" value="1" checked><label>You may share information with Reunion Committee only. <input type="radio" id="privacy" value="2"><label>You may share information with Alumni. <br> <center><a href="privacy.shtml" id="whiteLink">Privacy statement</a></center> <hr> <br> <span class="subheader">NEWSLETTER SURVEY</span> <br> <label>Would you want to receive an alumni newsletter, when and if it becomes available?</label> <br> <input type="radio" id="newsletter" value="1" checked><label>Yes</label> <input type="radio" id="newsletter" value="2"><label>No</label> <input type="radio" id="newsletter" value="3"><label>Undecided</label> <br> <br> <input type'hidden" id="memDate" value="<?php gmdate("l dS \of M Y H:i:s a")?>"> <input type'hidden" id="ip" value="<?php $ip=$_SERVER['REMOTE_ADDR'];?>"> <br> <hr> <br> <center> <input class="button" type="submit" value="Register"> <input class="button" type="reset" value="Clear"> </center> </form>
-
Nightslyer; I agree with you. I'm just learning PHP and doing my best to overcome my physical hanicaps. 1 - I cant see very well because of a recent tear in mt retna and getting it operated on. 2 - I cannot use my left side,( hands, arm, legs) since having a stroke, so I'm typing now with only one finger. Use to type 110wpm. 3 - I learn better by example. Reading because of my eyesight is somewhat difficult. But I try all the time. So you my think, You need to read on the computer. Yes, but I can enlarge the text so I can read it. 4 - I do this to keep my mind active and to learn. I just learn a little more slowly these days. So what my seem as a easy question to some, isn't to others. I don't post anything here unless I have at least tried to fix it myself. When I become frustrated, then I post and usually it's a missing character or a typo I made. I just posted a question about the if statement. I sure hope someone doesn't think I stupid because it's easy for them! Thanks for your comments.... Bob...
-
I am creating a class alumni web and ask a question tha requires selecting one of 3 radio buttons. If the user selects the 3rd button, I want to display an additional field. Here is the lines of code: <label>Are you or your spouse a Taft Class of 1965 alumni?</label> <input type="radio" id="alumni" value=1 checked><label>yes</label> <input type="radio" id="alumni" value=2><label>no</label> <br> <label>Are you a graduate of Taft Union High School?</label> <input type="radio" id="alumni" value=3><label>yes</label> Error ---> <?php // If alumni is equal to 3 display the input field If ($ans == 3);{ Echo "<input type='int' id='gradClass' size='4' maxlenght='4' placeholder='1977'>" } ?> <br> <hr> <br> <span class="subheader">PRIVACY</span> <br> And I didn't forget a ' this time. Could someone please assist. Thanks in advance.
-
Thank you for the assist. I should have spotted that. No excuse but at 68, my eyes arn't what they use to be. I'm going to enlarge the test with shift +. I'll check Eclipse out and see if that helps. NuSphere cost $200, I hope this is less. Thanks again for putting up with an old guy, but young at heart.
-
Here is the code you requested. This is another concern - I have created a rester table from which I grab data to populate some areas of this page. My concern is, do I have the open db in the correct place? <?php // Place the results in the proper locations. $firstname=$_POST['firstname']; $lastname=$_POST['lastname']; $email=$_POST['email']; $dbhost = 'localhost'; $dbuser = 'taft_boblan'; $dbpass = 'taft65_8e83bed3'; $dbname = 'taft65_members'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Unable to connect with Alumni Database. Try again later.); mysql_select_db($dbname); //create a SQL statement to obtain data from table register // populate fields id, email, firstname, and lastname from table register // if $errors is not empty, the form must have failed one or more validation // tests. Loop through each and display them on the page for the user if (!empty($errors)) { Error---> echo "<div style='width:100%;'>Please fix the following errors:\n<ul>"; foreach ($errors as $error) echo "<li>$error</li>\n"; echo "</ul></div>"; } if (!empty($message)) { echo "<div class='notify'>$success_message</div>"; }
-
Well, when you get one thing solved, another pops up its ugly head. Here's the latest error. Parse error: syntax error, unexpected T_STRING in /home/taft65/public_html/memProtest.php on line 205 Code: <?php // if $errors is not empty, the form must have failed one or more validation // tests. Loop through each and display them on the page for the user if (!empty($errors)) { line 205--> echo "<div style='width:100%;'>Please fix the following errors:\n<ul>"; foreach ($errors as $error) echo "<li>$error</li>\n"; echo "</ul></div>"; } if (!empty($message)) { echo "<div class='notify'>$success_message</div>"; } ?> I know my eyes aren't great and I'm typing with one finger, but I'll be darn if I see an error.
-
I Am getting along with php better than I was previously. But this 68 year old brain still refuses to learn very fast! Here is the error I'm receiving when I'm trying to open the db: Parse error: syntax error, unexpected T_VARIABLE in /home/taft65/public_html/memProtest.php on line 197 <?php error_reporting(E_ERROR | E_PARSE | E_CORE_ERROR); $host = "localhost"; $dbname="database;" Failing ------>$username = "user"; $password="drDedf#hj"; I understand you do not need to declare varibles in PHP, Correct? I checked the db to ensure that I'm calling the correct value. NuSpherePhpEd to validate the code. I also check it with DSV PHP Editor. Both come up with the same error. I'm also using MyPhpAdmin to create the database and tables. I know also to place this calling info in another folder and include it by calling it with a php include statement. I just have it within the code to quickly test it. Thank you for any assistance. Bob...
-
Almost got login right - Need a small bit of help
boblan66 replied to boblan66's topic in PHP Coding Help
I placed a couple of echos to check the data, and now nothing is shown. When I attempt to look at the source code, the page is blank, as though nothing is being interrupted. I took out the echo statements and the same thing happens. Any ideas? CODE: <?php // Open members db - ceck to ensure user is not previously logged in - if no log yhe user in to the mem_log table. // If yes display appropriate error message. /// Page Name: login.php /// Date: 11-9-10 Time: 7:28pm /// Tested: 11-7-10 by: bnl include "include/session.php"; include "include/z_db.php"; $userName=$_POST['userName']; $password=$_POST['password']; ?> <!doctype html> <html> <head> <title>Taft Union High School Alumni Class of 1965</title> <meta name="GENERATOR" content="NotePad++"> <meta name="FORMATTER" content="NotePad++"> </head> <body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000"> <?php $userName=mysql_real_escape_string($userName); $passWord=mysql_real_escape_string($passWord); //////// echo $userName $sql_query = mysql_query("SELECT * FROM `signup` WHERE `userName`='$userName' AND `passWord` = '$passWord' LIMIT 1"); if (mysql_num_rows($sql_query) > 0) { //log session data include "include/newsession.php"; $tm=date("Y-m-d H:i:s"); //$ip=@$REMOTE_ADDR; // The above line is commented and the line below is used for the servers where register_global=Off $ip=$_SERVER['REMOTE_ADDR']; echo $ip; $rt=mysql_query("insert into mem_login(id,userName,ip,tm) values('$_SESSION[id]','$_SESSION[userName]','$ip','$tm')"); // Username and password passed redirect to memPage header("location: memPage.html"); session_unset(); } else { // RUN YOUR ERROR MESSAGE echo " <div style='width:350px; border: medium ridge navy; background-color:gold; padding:10px;' > <table border='0' cellspacing='0' cellpadding='3' align='center bgcolor='gold'> <th style='font-weight:bold; fony-size:1,4em;color:#FFFFFF;background-color:red;'> INCORRECT USERNAME OR PASSWORD <hr> </th> <tr> <td>The username or Password was not located in the database, Check to ensure you have the correct information. If you need assistance, contact the site administrator at: <br> http://[email protected]. <br><br> <center> <input type='button' value='Retry' onClick='history.go(-1)'> </center> </td> </tr> </table> </div> "; } ?> </body> </html> [attachment deleted by admin] -
Almost got login right - Need a small bit of help
boblan66 replied to boblan66's topic in PHP Coding Help
Let me do that! Thanks for the fast reply.