Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- in dreamweaver i get syntar error on line 103 that the second to last line line in the code...And on wamp server i get this: Parse error: syntax error, unexpected $end in C:\wamp\www\register\register.php on line 105
- please help me...
- <head>
- <?php
- // Don't put your includes in the middle of the code!
- require_once ('connect_to_mysql.php');
- function show_form()
- {
- $txt = "<h1>Register To Govana Designs</h1>";
- $txt .= "<form action='register.php' method='POST'>
- $txt .= <table>;
- $txt .= <tr> <td> First name: </td> <td> <input type='text' name='firstname' value='".$firstname."' /> </td> </tr>";
- $txt .= "<tr> <td> Last name: </td> <td> <input type='text' name='lastname' value='".$lastname."' /> </td> </tr>";
- $txt .= "<tr> <td> Enter a username: </td> <td> <input type='text' name='username' value='".$username."' /> </td> </tr>";
- $txt .= "<tr> <td> Email: </td> <td> <input type='email' name='email' value='".$email."' /> </td> </tr>";
- $txt .= "<tr> <td> Enter a password: </td> <td> <input type='password' name='password' /> </td> </tr>";
- $txt .= "<tr> <td> Comfim password: </td> <td> <input type='password' name='confirmpassword' /> </td> </tr>";
- $txt .= "</table>";
- $txt .= "<p> <input type='submit' name='submit' value='Register' /> </p>";
- $txt .= "</form>";
- return($txt);
- }
- function deal_with_form()
- {
- // Cleanup variables
- // no need to use "isset": ALL variables WILL be set, since the form has been sent.
- // howver, the variables VALUES may be blank!
- $firstname = strip_tags ($POST['firstname']);
- $lastname = strip_tags ($POST['lastname']);
- $username = strtolower (strip_tags($POST['username']));
- $email = strip_tags ($POST['email']);
- $password = strip_tags ($POST['password']);
- $comfirmpassword = strip_tags($POST['confirmpassword']);
- $datum = date("Y-m-d");
- // don't use "date": it is confusing with the function!
- // Although you should the validity of the field in javascript BEFORE sending the form,
- // you can check them here...
- if (($firstname == "firstname") || ($lastname == "lastname"))
- return ("missfields");
- if ( 'any other checks here' ) // if fail, return
- return ("incorrect");
- // Check if exists in DB
- $con = mysql_connect("localhost","root","");
- mysql_select_db("phplogin");
- $sql = "select `username` from `users` where `username`='" . $username . "' ";
- // recommended: all lower cases
- // note the syntax!
- // build your query separately, so you can use it in case of problems.
- $res = mysql_query($sql) or die ("Error: sql=" .$sql. "<br>" . mysql_error());
- // your previous query was incorrect (your mysql_num_rows would not work: you must use the return POINTER to results from the query )
- $cnt = mysql_num_rows($res);
- if ($cnt == 0) // register!
- {
- // Encrypt password
- $pwd = md5($password);
- // build sql:
- $datum = date("Y-m-d");
- $sql = "insert into `users` (`id`, `firstname`, 'lastname', `username`, 'email', `password`, `datum` )
- values = ( NULL , '".$firstname."', '".$lastname."', '".$username."', '".$email."', '".$pwd."', '".$datum."' )";
- // change the field "date" in table to "datum: "date" is a keyword!!!
- mysql_query($sql); // do the insert.
- mysql_close($con);
- return("pass");
- }
- else
- {
- mysql_close($con);
- return ("taken");
- }
- {
- ?>
- </head>
- <html>
- <body>
- <?php
- if (!isset($_POST['submit'])) // $_POST is not set yet: first pass
- echo (show_form());
- else // $_POST is set: this code just received the form!
- {
- $res = deal_with_form();
- switch ($res)
- {
- case "pass":
- echo "You have just registered to Govana Designs! <a href='index.php'>Return to login page</a>";
- break;
- case "taken":
- echo "<p>Sorry, this name is already taken<p>";
- unset ($_POST['submit']);
- echo (show_form());
- break;
- case "incorrect":
- echo "<p>Sorry, some fields are incorrect</p>";
- unset ($_POST['submit']);
- echo (show_form());
- break;
- case "missfields":
- echo "<p>You must complete all fields</p>";
- unset ($_POST['submit']);
- }
- }
- ?>
- </body>
- </html>
- line 105
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement