Hi
Maybe wanting to be a female web developer is getting to me. Really pushing tho.
I urgently need assistance. I am soo new to php and struggling * have cried, slept and still crying*
I have created a user registration page where the user registers, the information is sent to the database and from there if the information is correct the user is linked to the login page.
From the login page the user is able to able to insert data into the insert page, this page will also list the existing businesses that have inserted.
The admin(user) will be able to delete or edit the data inserted.
Problem.
- Do i need to create a separate index.php page and a register page, how do i link the register page and the index.php page?? The index.php page contains my logo, and my form. My registration page contains my registration.php script.
- Do i also create a separate page for my login.php form that just has my script and another page that has the html form? This applies to my insert and update page as well.
- My coding doesnt seem rite as when i test the site(pages) when i click register it opens the register.php pgae instead of processing the script.
Note:
The register and login page inserts the data into the ‘users table’ in the web25d1 database and the insert and list pages insert data into the business table in the web25d1 database.
Index page - justt the html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>index.php</title>
</head>
<body>
<table width="800" border="0" cellspacing="3" cellpadding="3">
<tr>
<th scope="col" bgcolor="#ffffff">
<img src="header.jpg" alt="business_online" width="846" height="148" align="left" /> </th>
</tr>
</table>
<table width="856" border="0" cellspacing="3" cellpadding="3" bgcolor="#6699CC">
<tr>
<th width="257" scope="col">
<a href="register.php" target="_blank" class="nav">REGISTER</a> </th>
<th width="176" scope="col">
<a href="login.php" target="_blank">LOGIN</a> </th>
<th width="190" scope="col">
<a href="insert.php" target="_blank" class="nav">INSERT</a> </th>
<th width="194" scope="col">
<a href="list.php" target="_blank" class="nav">LIST</a> </th>
</tr>
</table>
<p><br/>
<strong class="h1">Welcome to Business Online, Please fill in your details below to register.</strong><br/>
</p>
<form name="form1" method = "post" action="register.php">
<div align="left">
<table width="300" border="0" cellspacing="3" cellpadding="3">
<tr> <td>Title: </td> <td>
<select name = "dropdown" value ="title">
<option value"registration.php"> </option>
<option value = "1"> Mr </option>
<option value = "2"> Mrs </option>
<option value = "3"> Ms </option>
<option value = "4" > Miss </option>
<option value = "5" > Prof </option>
<option value = "6"> Dr </option>
<option value = "7"> Mnr </option>
<option value = "8"> Mev </option>
</select> </td>
</tr>
<tr> <td>Name: </td> <td>
<input type = "text" name = "name" maxlength = "50"></td>
</tr>
<tr> <td>Surname:</td> <td>
<input type = "text" name = "surname" maxlength = "50"></td>
</tr>
<tr> <td>username:</td> <td>
<input type = "text" name = "username" maxlength = "30"></td>
</tr>
<tr> <td>password:</td> <td>
<input type = "password" name = "password" maxlength = "10"></td>
</tr>
<tr> <td>confirm password:</td> <td>
<input type = "password" name = "password2" maxlength = "10"></td>
</tr>
<tr> <td>
<div align="center">
<input name="Submit" type="submit" value="Register">
</div></td>
</tr>
</table>
</div>
<div align="left"></div></form>
<div align="center">
</div>
</body>
</html>
</body>
</html>
- The register page that has to link with the index page(home page)
[php]
" } ; $title = mysql_escape_string($_POST ['title']); $fname = mysql_escape_string($_POST ['fname']); $sname = mysql_escape_string($_POST ['sname']); $uname = mysql_escape_string($_POST ['uname']); $pass1 = mysql_escape_string($pass1); $pass2 = mysql_escape_string($pass2); $pass1 = md5($pass1); $sql = mysql_query("SELECT* FROM `users` WHERE `username` = '$uname'") ; if (mysql_num-rows($sql)>0){ echo "Sorry, that user already exists."; exit(); } mysql_query("INSERT INTO `users`(`id`, `title`,`fname`, `sname`, `uname`, `pass`)VALUES (NULL , '$title', '$fname', '$sname', '$uname', '$pass')") or die(mysql_error()); } else{ echo "Sorry, your passwords do not match.
"; exit (); } }else { $form = <<<EOT Title:
Name:
Surname:
Username:
Password:
Confirm Password:
EOT; echo $form ; } ?>
[/php]
- The login page
[php]
<?php include('conect.php') or die ("Cannot find the config file."); if(isset($_POST['submit'])){ $uname = mysql_escape_string($_POST['uname']); $pass = mysql_esacpe_string($_POST ['pass']); $pass = md5($pass); $sql = mysql_query("SELECT * FROM `users` WHERE `uname` = '$uname' AND `pass` = '$pass'"); if(mysql_num_rows($sql)> 0 ){ echo "You are now logged in."; exit(); }else { echo "Wrong username and password combination"; } } else { $form = <<<EOT Username:Password:
EOT; echo $form; } ?>
[/php]
- The insert page
[php]
<?php include('connect.php') or die ("Cannot find the connect file file."); //Connect to the server and select database mysql_connect ("127.0.0.1", "root", "") or die("cannot connect"); mysql_select_db("$web25db1") or die ("cannot select DB"); //Get values from form $name = $_POST ['bname']; $business_type = $_POST ['btype']; $address = $_POST ['address']; $email = $_POST ['email']; $contact_number = $_POST ['cnumber']; $conact_person ['cperson']; //Insert data in the database $sql= "INSERT INTO $business(`bname`,`btype`, `address`,`email`, `cnumber`,`cperson`) VALUES ('$name', '$business_type', '$address', '$email', '$contact_number', '$contact_person')"; //If successfully insert data into database, display message" Business details added". if($result){ echo" Business details updated"; echo ""; echo " Back to main page "; } else { echo "ERROR"; } ?> <?php //close connection mysql_close (); ?>
[/php]
- The list page
[php]
<?php require ('conect.php') or die ("Cannot find the config file."); //Connect to the server and select database mysql_connect ("127.0.0.1", "root", "") or die("cannot connect"); mysql_select_db ($web25db1) or die ("cannot select DB"); //select record from mysql $sql = "SELECT * FROM $business_details"; $result = mysql_query($sql); ?>| Business List | |||||||
| Id | Name | Business Type | Address | Contact Number | Contact Person | Action |
[/php]
Its a bit messy, I apologize for that. I hope you will able to understand and assist.
Thank you soo much.