Jump to content

Making a login page with "PHP and MYSQL for Dummies"


Akskater1000

Recommended Posts

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>

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.