ok i need to send info that is entered on this form </div> <!-- end of navigation div --> <form action="" method="post" class="register"> <fieldset> <legend>Registration</legend> <div> <label for="name" class="fixedwidth">Name:</label> <input type="text" name="name"id="name" /> </div> <div> <label for="username" class="fixedwidth">Username:</label> <input type="text"name="username id="username" /> </div> <div> <label for="password" class="fixedwidth">Password:</label> <input type="text"name="password id="password" /> </div> <div> <label for="email" class="fixedwidth">Email:</label> <input type="text"name="email id="email" /> </div> <div> <label for="parkname" class="fixedwidth">Park Name:</label> <input type="text"name="parkname id="parkname" /> </div> <div> <label for="parklocation" class="fixedwidth">Park Location:</label> <input type="text"name="parklocation id="parklocation" /> </div> <div> <label for="caravandetails" class="fixedwidth">Caravan Details:</label> <input type="text"name="caravandetails id="caravandetails" /> </div> <div> <label for="photo" class="fixedwidth">Photo:</label> <input type="file"name="photo id="photo" /> </div> </fieldset> <input type="submit" class="submit" value="Add" /> <input type="reset" class="reset" value="Clear Form" /> </div> </form> HTML: to add to database php script <?php //This is the directory where images will be saved $target = "images/"; $target = $target . basename( $_FILES['photo']['name']); $ok=1; if ($uploaded_size > 350000) { echo "Your file is too large.<br>"; $ok=0; } if ($uploaded_type =="text/php") { echo "No PHP files<br>"; $ok=0; } if ($ok==0) { echo "Sorry your file was not uploaded"; } //This gets all the other information from the form $name=$_POST['name']; $username=$_POST['username']; $password=$_POST['password']; $email=$_POST['email']; $parkname=$_POST['parkname']; $parklocation=$_POST['parklocation']; $caravandetails=$_POST['caravandetails']; $pic=($_FILES['photo']['name']); // Connects to your Database mysql_connect("abc.com", "abc", "abc") or die(mysql_error()) ; mysql_select_db("abc") or die(mysql_error()) ; //Writes the information to the database mysql_query("INSERT INTO `members` VALUES ('$name', '$username', '$password', '$email', '$parkname', '$parklocation', '$caravandetails', '$pic')") ; //Writes the photo to the server if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) { //Tells you if its all ok echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directoryYou will be redirected in three seconds!><br /><br /> <div class='info'>If you don't wish to wait, <a href='index.html'>click here</a>"; echo'<meta http-equiv="REFRESH" content="3;url=index.html">'; } else { //Gives and error if its not echo "Sorry, there was a problem uploading your file."; } ?> PHP: cheers Doug
This is very easy. Save your database PHP script in its own file, say it's called: script.php Then in your html code, find the part that says: <form action="" and change it to: <form action="script.php" That should be all you need to do - unless there are any bugs in the code. If that doesn't work, post back here and i'll have a closer look at your code.
have changed the html code in reg form it trys to post but get error from php form </div> <!-- end of navigation div --> <form action="add.php" enctype="multipart/form-data" id="add" method="post"> <div class="fieldset"> <fieldset> <legend>Registration</legend> <label for="name">Name:</label> <input type="text" id="name" /><br /> <label for="username">Username:</label> <input type="text" id="username" /><br /> <label for="password">Password:</label> <input type="password" id="password" /><br /> <label for="e-mail">E-Mail:</label> <input type="text" id="e-mail" /><br /> <label for="park-name">Park Name:</label> <input type="text" id="park-name" /><br /> <label for="park-location">Park Location:</label> <input type="text" id="park-location" /><br /> <label for="caravan-details">Caravan Details:</label> <input type="text" id="caravan-details" /><br /> <label for="photo">Photo:</label> <input type="file" id="photo" /> </fieldset> </div> <div> <input type="submit" class="submit" value="Add" /> <input type="reset" class="reset" value="Clear Form" /> </div> </form> HTML:
ok got it sorted for posting to database just need the form fields to line up cheers Doug <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Caravan Holidy Exchange - The static caravan owners club</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link href="style1.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="header"> <div id="sitebranding"> <h1>Caravan-Holiday-Exchange.com</h1> </div> <div id="tagline"> <p>The static caravan owners club</p> </div> </div> <!-- end of header div --> <h1>Register</h1> <div id="mainnavigation"> <h3>Site Navigation</h3> <ul> <li><a href="index.html" herf="index.html">Home</a></li> <li><a href="about.html" herf="about.html">About Us</a></li> <li><a href="contact.html" herf="contact.html">Contact Us</a></li> <li><a href="register.html" herf="form2.html">Register</a></li> </ul> </div> <!-- end of navigation div --> <form enctype="multipart/form-data" action="add.php" method="POST"> Name: <input type="text" name="name"><br> Username: <input type="text" name="username"><br> Password: <input type="text" name="password"><br> E-mail: <input type="text" name = "email"><br> Park Name: <input type="text" name="parkname"><br> Park Location: <input type="text" name="parklocation"><br> Caravan Details: <input type="text" name="caravandetails"><br> Photo: <input type="file" name="photo"><br> <input type="submit" value="Add"> </form> </div> </body> </html> HTML: