Akskater1000 Posted January 4, 2009 Share Posted January 4, 2009 I have PHP and MYSQL for Dummies, and there's a section to make a login page and register page from scratch. I took the tutorial, but I get this error on it "Parse error: parse error in C:\wamp\www\index.php on line 75" Here's the code: <?php /* File: login_reg_form.inc * Desc: Contains the code for a Web page that displays * two HTML forms, side by side. One is a login * form, and the second is a registration form. */ include("functions.inc"); ?> <head><title>Customer Login Page</title> <style type='text/css'> <!-- label { font-weight: bold; float: left; width: 27%; margin-right: .5em; } legend { font-weight: bold; font-size: 1.2em; margin-bottom: .5em; #wrapper { margin: 0; padding: 0; } #login { position: absolute; left: 0; width: 40%; padding: 1em 0; } #reg { position: absolute; left: 40%; width: 60%; padding: 1em 0; } #feild {padding-bottom: .5em;} .errors { font-weight: bold; font-style: italic; font-size: 90%; color: red; margin-top: 0; } --> </style> </head> <body style="margin: 0"> <?php $fields_1 = array("fusername" => "User Name", "fpassword" => "Password" ); $fields_2 = array("user_name" => "User Name", "password" => "Password", "email" => "Email", "first_name" => "First Name", "last_name" => "Last Name", "nickname" => "Nickname" ); ?> <div id="wrapper"> <div id="login"> <form action=<?php echo $SERVER['PHP_SELF']?> method="POST"> <fieldset style='border: 2px solid #000000'> <legent>Login Form</legent> <?php if (isset($message_1)) { echo "<p class='errors'>$message_1</p>\n"; } foreach($fields_1 as $field => $value) { if(preg_match("match("/pass/i",$field)) $type = "text"; else $type = "text"; echo "<div id='field'> <label for='$field'>$value</label> <input id='$field' name='$field' type='$type' value='".@$$field."' size='20' maxlength='5-' /> </div>\n"; } ?> <input type="submit" name="Button" stype='margin-left: 45%; margin-bottom: .5em' </fieldset> </form> <p style='text-align: center; margin: 1em'> If you already have an account, log in.</p> <p style='text-align: center; margin: 1em'> If you do not have an account, register now.</p> </div> <div id="reg"> <form action=<?php echo $_SERVER['PHP_SELF']?> method="POST"> <fieldset style='border: 2px solid #000000'> <legend>Registration Form</legend> <?php if(isset($message_2)) { echo "<[ class='errors'>$message_2</p>\n"; } foreach{$fields_2 as $field => $value) { if($fields == "state") { echo "<div id='field'> <label for='$field'>$value</label> <select name='state' id='state'>"; $stateName=getStateName(); $stateCode=getStateCode(); for ($n=1;$n<=50;$n++) { $state=$stateName[$n]; $scode=$stateCode[$n]; echo "<option value='$scode'"; if ($scode== "AL") eho " selceted"; echo ">$state</option>\n"; } echo"</select></div>"; } else { if(preg_match("/pass/i",$field)) $type = "password"; else @type = "text"; echo "<div id='field'> <label for=$field'>$value</label> <input id=$field' name='$field' type='$type' value='".@$$field."' size='40' maxlength='65' /> </div>\n"; } //end else } // end foreach field ?> <input type="submit" name="Button" style='margin-left: 45%; margin-bottom: .5em' value="Register"> </fieldset> </form> </div> </div> </body></html> Quote Link to comment https://forums.phpfreaks.com/topic/139388-making-a-login-page-with-php-and-mysql-for-dummies/ Share on other sites More sharing options...
DarkWater Posted January 4, 2009 Share Posted January 4, 2009 There's a lot of stuff askew in that code... <form action=<?php echo $SERVER['PHP_SELV']?> if(preg_match("match("/pass/i",$field)) $type = "text"; else $type = "text"; eho " selceted"; @type = "text"; Is code this atrocious really in that book? Or are these just typos from retyping it by hand? Quote Link to comment https://forums.phpfreaks.com/topic/139388-making-a-login-page-with-php-and-mysql-for-dummies/#findComment-729074 Share on other sites More sharing options...
Akskater1000 Posted January 4, 2009 Author Share Posted January 4, 2009 They're typos from retyping it. Thanks for spotting those. xD But could you tell me what's wrong with them? I fixed the first. That's easy to see. EDIT: Never mind. I found what's wrong with them. EDIT2: Okay I fixed all of those, but I still get " Parse error: parse error, expecting `'('' in C:\wamp\www\index.php on line 105" I'm using Notepad to edit the .php files, so I can't figure out which is line 105... Quote Link to comment https://forums.phpfreaks.com/topic/139388-making-a-login-page-with-php-and-mysql-for-dummies/#findComment-729096 Share on other sites More sharing options...
premiso Posted January 4, 2009 Share Posted January 4, 2009 They're typos from retyping it. Thanks for spotting those. xD But could you tell me what's wrong with them? I fixed the first. That's easy to see. EDIT: Never mind. I found what's wrong with them. EDIT2: Okay I fixed all of those, but I still get " Parse error: parse error, expecting `'('' in C:\wamp\www\index.php on line 105" I'm using Notepad to edit the .php files, so I can't figure out which is line 105... Download notepad++ if you plan on actually coding. It highlights syntax etc for PHP and what not. Great small and free program imo. When you find 105 you should be able to figure out the error, if not post it and we will help. Quote Link to comment https://forums.phpfreaks.com/topic/139388-making-a-login-page-with-php-and-mysql-for-dummies/#findComment-729101 Share on other sites More sharing options...
Akskater1000 Posted January 4, 2009 Author Share Posted January 4, 2009 Okay. I figured out the rest. And yea, my friend told me to download NotePad+ so I did, but it doesn't hightlight anything... I spam typed random letters. It all remained the same color... Quote Link to comment https://forums.phpfreaks.com/topic/139388-making-a-login-page-with-php-and-mysql-for-dummies/#findComment-729107 Share on other sites More sharing options...
premiso Posted January 4, 2009 Share Posted January 4, 2009 You have to have the <?php ?> tags for it to highlight. It also has to have the right extension. So a new file needs to saved as a .php for proper highlighting. Quote Link to comment https://forums.phpfreaks.com/topic/139388-making-a-login-page-with-php-and-mysql-for-dummies/#findComment-729108 Share on other sites More sharing options...
revraz Posted January 4, 2009 Share Posted January 4, 2009 Go to the Misc forum here and look at the Editor thread. Get yourself a nice free editor. Even the errors you posted here had typos in them. Quote Link to comment https://forums.phpfreaks.com/topic/139388-making-a-login-page-with-php-and-mysql-for-dummies/#findComment-729122 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.