hi
having problems with creating a database using php5 and mysql 4.1. ive set up database and test everything to make sure they are talking to each other. try to now link my php page to the database some people can enter information to the database.
im working from php and mysql for dynamic website 2nd edition which so far has been great. not sure what the problem is but getting this message after i enter info into my form and submit it.
Not Found
The requested URL /p06238194/register-address.php was not found on this server.
Apache/2.0.54 (Win32) PHP/5.0.5 Server at localhost
this is the code which i wriiten out from using the book, would be great if someone could give me some pointers as im working on this for my uni dissertation.
<?php # script - register_address.php
$page_title = 'Register Address';
//check if the form has been submitted
if (isset($_POST['submitted'])) {
//initialize error array
$errors = array();
//check for a number
if (empty($_POST['number'])) {
$errors[] = 'Please enter house/flat name/number';
}else{
$n = trim($_POST['number']);
}
//check for first line
if (empty($_POST['fistline'])) {
$errors[] = 'Please enter first line of address';
}else{
$fl = trim($_POST['firstline']);
}
//check for second line
if (empty($_POST['secondline'])) {
$errors[] = 'Please enter second line of address';
}else{
$sl = trim($_POST['secondline']);
}
//check for city
if (empty($_POST['city'])) {
$errors[] = 'Please enter city';
}else{
$c = trim($_POST['city']);
}
//check for county
if (empty($_POST['county'])) {
$errors[] = 'Please enter county';
}else{
$co = trim($_POST['county']);
}
//check for postcode
if (empty($_POST['postcode'])) {
$errors[] = 'Please enter postcode';
}else{
$pc = trim($_POST['postcode']);
}
//add the information submitted to the database
//first line inserts contents of connect.php into the script.
require_once ('../mysql_connect.php');
//the query for the database
$query = "INSERT INTO address
(number, firstline, secondline, city, county, postcode)
VALUES ('$n', '$fl', '$sl', '$c', '$co', '$pc', )";
$result = @mysql_query ($query);
//it query run ok
if ($result) {
echo '<p> It entered ok, well done chris!!</p>';
include (' ./includes/footer.html');
exit();
}else{
echo '<p> it didnt work chris</p>';
echo '<p>' . mysql_error()
. '<br /><br />Query: ' . $query . '</p>';
include (' ./includes/footer.html');
exit();
}
//close database connection
mysql_close();
}
?>
<form action="register-address.php" method="post">
<!-- field set states the kind of form, this can be changed-->
<fieldset><legend>Please enter your accommodations details below:</legend>
<!--text boxes for data-->
<p><b>Number:</b> <input type="text"
name="number" size="20"
maxlength="40" /></p>
<p><b>First Line of Address:</b> <input type="text"
name="firstline" size="40"
maxlength="60" /></p>
<p><b>Second Line of Address:</b> <input type="text"
name="secondline" size="40"
maxlength="60" /></p>
<p><b>City:</b> <input type="text"
name="city" size="40"
maxlength="60" /></p>
<p><b>County:</b> <input type="text"
name="county" size="20"
maxlength="40" /></p>
<p><b>Postcode:</b> <input type="text"
name="postcode" size="20"
maxlength="40" /></p>
<!--radio buttons-->
<p><b>Please select items which are included in the rent</b></p>
<p><input type="radio" name="water" value="water" /> Water </p>
<p><input type="radio" name="Gas" value="gas" /> Gas </p>
<p><input type="radio" name="electricity" value="electricity" /> Electricity </p>
<p><input type="radio" name="internet" value="internet" /> Internet </p>
<p><input type="radio" name="tv" value="tv" /> TV </p>
<p><input type="radio" name="cable-sky" value="cable-sky" /> Cable or Sky TV </p>
<p><input type="radio" name="cleaning" value="cleaning" /> Cleaning </p>
<p><b>Facilities Avaliable</b></p>
<p><input type="radio" name="furniture" value="furniture" /> Furniture </p>
<p><input type="radio" name="washer-dryer" value="washer-dryer" /> Washer/Dryer </p>
<p><input type="radio" name="cooker" value="cooker" /> Cooker </p>
<p><input type="radio" name="fridge-freezer" value="fridge-freezer" /> Fridge/Freezer </p>
<p><input type="radio" name="double-glazing" value="double-glazing" /> Double Glazing </p>
<p><input type="radio" name="central-heating" value="central-heating" /> Central Heating </p>
<p><input type="radio" name="alarm" value="alarm" /> Alarm </p>
<p><input type="radio" name="fire-alarm" value="fire-alarm" /> Fire Alarm </p>
<p><input type="radio" name="door-locks" value="door-locks" /> Locks on Room Doors </p>
<p><input type="radio" name="parking" value="parking" /> Secure Off Street Parking </p>
<p><input type="radio" name="entrance" value="entrance" /> Secure/Buzz Entrance </p>
<!--drop down box-->
<p><b>Is rent paid:</b>
<select name="rent">
<option value="monthly"> Monthly</option>
<option value="weekly"> Weekly</option>
</select></p>
<!--closes fieldset-->
</fieldset>
<!--submit button, centered with div tag-->
<div align="center"><input type="submit" name"submit"
value="Submit" /></div>
<!--form is closed-->
</form>
</body>
</html>
thanks for looking and helping if you can 🙂
chris