Jump to content

lucy

Members
  • Posts

    98
  • Joined

  • Last visited

    Never

Everything posted by lucy

  1. I have tried adding my contact form which is php to the page and it screws up the menu system. I then added quite a lot of breaks in and it still would not fix it. I then took out the contact form and simply added <?php echo"hi" ?> and it still screwed up my layout. It should look like this, normally: but when i add the php element, with or without any breaks, the menue system is still screwed up (look at ABOUT, its been pushed up.) Even when i add several breaks, the "hi" moves down the page but the ABOUT button does not move to its normal position. Here is an image of how it looks with the php element in: Can anyone please help me, as this is driving me nuts!! Full HTML code of page with php element in: <!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></title> <link rel="stylesheet" type="text/css" href="../layout.css" /> <link rel="stylesheet" type="text/css" href="../tabmenu.css" /> <link rel="stylesheet" type="text/css" href="../mainmenu.css" /> </head> <body> <div id="header_container"> <img src="../images/header_right.jpg" align="right" /> <ul class="tabmenu"> <li class="residential"><a href="" class="selected"title="residential"><span class="displace">Residential</span></a></li> <li class="commercial"><a href="../commercial/about.html" title="commercial"><span class="displace">Commercial</span></a></li> </ul> <ul class="mainmenu"> <li class="about"><a href="about.html" title="about"><span class="displace">About</span></a></li> <li class="survey"><a href="survey.html" title="survey"><span class="displace">Survey</span></a></li> <li class="order"><a href="order.html" title="order"><span class="displace">Order</span></a></li> <li class="track"><a href="track.html" title="track"><span class="displace">Track</span></a></li> <li class="contact"><a href="" class="selected" title="contact"><span class="displace">Contact</span></a></li> <li class="faq"><a href="faq.html" title="faq"><span class="displace">FAQ</span></a></li> </ul> </div> <div id="content"> <?php echo "hi" ?> </div> </body> </html> Full code of a different page, with the menu system working fine: <!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></title> <link rel="stylesheet" type="text/css" href="../layout.css" /> <link rel="stylesheet" type="text/css" href="../tabmenu.css" /> <link rel="stylesheet" type="text/css" href="../mainmenu.css" /> </head> <body> <div id="header_container"> <img src="../images/header_right2.jpg" width="750" height="200" align="right" /> <ul class="tabmenu" > <li class="residential"><a href="../residential/about.html" title="Residential"><span class="displace">Residential</span></a></li> <li class="commercial"><a href="" class="selected" title="Commercial"><span class="displace">Commercial</span></a></li> </ul> <ul class="mainmenu"> <li class="about"><a href="" class="selected" title="About"><span class="displace">About</span></a></li> <li class="survey"><a href="survey.html" title="Survey"><span class="displace">Survey</span></a></li> <li class="order"><a href="order.html" title="Order"><span class="displace">Order</span></a></li> <li class="track"><a href="track.html" title="Track"><span class="displace">Track</span></a></li> <li class="contact"><a href="contact.php" title="Contact"><span class="displace">Contact</span></a></li> <li class="faq"><a href="faq.html" title="FAQ"><span class="displace">FAQ</span></a></li> </ul> </div> <div id="content"><h1>Commercial about </h1> <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur porttitor lobortis odio, at tincidunt nulla sagittis et. Donec gravida nulla sit amet purus faucibus elementum. Duis ac urna at arcu convallis dignissim at in nibh. Aliquam a molestie mi. Ut accumsan, felis vel vestibulum elementum, leo ur</p> </div> <div id="footer_container">FOOTER</div> </body> </html> Layout.CSS: /*Page styles*/ * { margin: 0; } body { background-color:#e4e4e4; padding-left:5px; padding-right:5px; max-width:982px; margin-left:auto; margin-right:auto; } /*Header styles */ #header_container { min-height:200px; min-width:978px; margin-left:auto; margin-right:auto; background-image:url(images/header_tile2.jpg); background-repeat:repeat-x; border-right-style:solid; border-right-width:thin; border-right-color:#737373; border-left-style:solid; border-left-width:thin; border-left-color:#737373; } #header_container p { text-indent:60px; font-size:20px; } /*Main content styles */ #content { border-right-style:solid; border-right-width:thin; border-right-color:#737373; border-left-style:solid; border-left-width:thin; border-left-color:#737373; background-color:#FFF; min-width:978px; margin-left:auto; margin-right:auto; } #footer_container { text-align:center; height:50px; margin-left:auto; margin-right:auto; background-image:url(images/header_tile2.jpg); background-repeat:repeat-x; } #footer_container ul li { margin-left:0px; padding-right:20px; padding-left:20px; display:inline; font-size:11px; margin-top:50%; } li.border { border-right-style:solid; border-right-color:#000; border-right-width:thin; } Tabmenu.CSS ul.tabmenu { list-style: none; padding: 0px; padding-top:148px; margin-left:0px; margin-bottom:8px; left:0px; } .displace { position: absolute; left: -5000px; } ul.tabmenu li { float: left; } ul.tabmenu li a { display: block; width: 96px; height: 52px; background: url('images/tabs.jpg'); } /* * Normal Links */ ul.tabmenu li.residential a { background-position: 0 0; } ul.tabmenu li.commercial a { background-position: -96px 0; } /* * Hover Links */ ul.tabmenu li.residential a:hover { background-position: 0 -52px; } ul.tabmenu li.commercial a:hover { background-position: -96px -52px; } /* * Selected/Active Links */ ul.tabmenu li.residential a.selected { background-position: 0 -104px; } ul.tabmenu li.commercial a.selected { background-position: -96px -104px; } Mainmenu.CSS ul.mainmenu { list-style: none; padding: 0px; padding-top:0px; margin-left:0px; left:0px; } .displace { position: absolute; left: -5000px; } ul.mainmenu li { float: left; } ul.mainmenu li a { display: block; width: 163px; height: 44px; background: url('images/menu.jpg'); } /* * Normal Links */ ul.mainmenu li.about a { background-position: 0 0; } ul.mainmenu li.survey a { background-position: -163px 0; } ul.mainmenu li.order a { background-position: -326px 0; } ul.mainmenu li.track a { background-position: -489px 0; } ul.mainmenu li.contact a { background-position: -652px 0; } ul.mainmenu li.faq a { background-position: -815px 0; } /* * Hover Links */ ul.mainmenu li.about a:hover { background-position: 0 -44px; } ul.mainmenu li.survey a:hover { background-position: -163px -44px; } ul.mainmenu li.order a:hover { background-position: -326px -44px; } ul.mainmenu li.track a:hover { background-position: -489px -44px; } ul.mainmenu li.contact a:hover { background-position: -652px -44px; } ul.mainmenu li.faq a:hover { background-position: -815px -44px; } /* * Selected/Active Links */ ul.mainmenu li.about a.selected { background-position: 0 -88px; } ul.mainmenu li.survey a.selected { background-position: -163px -88px; } ul.mainmenu li.order a.selected { background-position: -326px -88px; } ul.mainmenu li.track a.selected { background-position: -489px -88px; } ul.mainmenu li.contact a.selected { background-position: -652px -88px; } ul.mainmenu li.faq a.selected { background-position: -815px -88px; } Please please can someone offer a reason as to why this is happening? Thanks a lot for the time to read this lengthy post Lucy
  2. So far, i have it so it highlights the field which is not filled in, i.e. if name is not filled in when submit is clicked, it brings the form back with the data and highlights the name field. but if more than one field are not filled in, it only highlights the top one, and then if the second one is not filled in, after submit is clicked, it will bring the form back and then highlight the second. Is there any way in which when submitted is clicked, that all fields with no text in are highlighted? fully working code: <?php $name = $_REQUEST['name'] ; $email = $_REQUEST['email'] ; $subject = $_REQUEST['subject'] ; $message = $_REQUEST['message'] ; $finalmessage = "This email has been sent to you from the online contact form\n\nName: $name\nEmail: $email\nSubject: $subject\n\nMessage: ". $message; if (!isset($_REQUEST['email'])) { echo "<html> <body> <form method='post' action='contact2.php'> Name: <input type='text' name='name' id='name'> <br /> <p>Email: <input type='text' name='email'/> </p> <p>Subject: <input type='text' name='subject' id='subject' > </p> <p><br /> Message:<br /> <textarea name='message' rows='15' cols='40'> </textarea> <br /> <input type='submit'/> </p> </form> </body> </html>"; } elseif (empty($name)) { echo "<b>Please complete all fields!</b>"; echo "<html> <body> <form method='post' action='contact2.php'> <p style='color:red'>Name: <input type='text' name='name' id='name' value='{$_POST['name']}'> </p> <p>Email: <input type='text' name='email' value='{$_POST['email']}'/> </p> <p>Subject: <input type='text' name='subject' id='subject' value='{$_POST['subject']}'> </p> <p> Message:<br /> <textarea name='message' rows='15' cols='40' value='{$_POST['message']}'> </textarea> <br /> <input type='submit'/> </p> </form> </body> </html>"; } elseif (empty($email)) { echo "<b>Please complete all fields!</b>"; echo "<html> <body> <form method='post' action='contact2.php'> <p>Name: <input type='text' name='name' id='name' value='{$_POST['name']}'> </p> <p style='color:red'>Email: <input type='text' name='email' value='{$_POST['email']}'/> </p> <p>Subject: <input type='text' name='subject' id='subject' value='{$_POST['subject']}'> </p> <p> Message:<br /> <textarea name='message' rows='15' cols='40' value='{$_POST['message']}'> </textarea> <br /> <input type='submit'/> </p> </form> </body> </html>"; } elseif (empty($subject)) { echo "<b>Please complete all fields!</b>"; echo "<html> <body> <form method='post' action='contact2.php'> <p>Name: <input type='text' name='name' id='name' value='{$_POST['name']}'> </p> <p>Email: <input type='text' name='email' value='{$_POST['email']}'/> </p> <p style='color:red'>Subject: <input type='text' name='subject' id='subject' value='{$_POST['subject']}'> </p> <p> Message:<br /> <textarea name='message' rows='15' cols='40' value='{$_POST['message']}'> </textarea> <br /> <input type='submit'/> </p> </form> </body> </html>"; } elseif (empty($message)) { echo "<b>Please complete all fields!</b>"; echo "<html> <body> <form method='post' action='contact2.php'> <p>Name: <input type='text' name='name' id='name' value='{$_POST['name']}'> </p> <p>Email: <input type='text' name='email' value='{$_POST['email']}'/> </p> <p>Subject: <input type='text' name='subject' id='subject' value='{$_POST['subject']}'> </p> <p style='color:red'> Message:<br /> <textarea name='message' rows='15' cols='40' value='{$_POST['message']}'> </textarea> <br /> <input type='submit'/> </p> </form> </body> </html>"; } else { mail( "EMAIL", "Feedback Form Results - '$subject'", $finalmessage, "From: $email\nName:$name\n" ); header( "Location: http://www.google.com" ); } ?>
  3. Works like a dream. Thanks :D
  4. Thanks i keep getting an error message, i think it is to do with the ' marks and " marks used. I cant figure out how to fix it. Error message is: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/sites/****.co.uk/public_html/contact2.php on line 40 Ive edited my code a little, and also tried putting the code you gave me into different speach marks but it does not seem to be working. full code: <?php $name = $_REQUEST['name'] ; $email = $_REQUEST['email'] ; $subject = $_REQUEST['subject'] ; $message = $_REQUEST['message'] ; $finalmessage = "This email has been sent to you from the online contact form at ****.co.uk.\n\nName: $name\nEmail: $email\nSubject: $subject\n\nMessage: ". $message; if (!isset($_REQUEST['email'])) { echo "<html> <body> <form method='post' action='contact2.php'> Name: <input type='text' name='name' id='name'> <br /> <p>Email: <input type='text' name='email'/> </p> <p>Subject: <input type='text' name='subject' id='subject' > </p> <p><br /> Message:<br /> <textarea name='message' rows='15' cols='40'> </textarea> <br /> <input type='submit'/> </p> </form> </body> </html>"; } elseif (empty($email) || empty($subject) || empty($message) || empty($name)) { echo "<b>Please complete all fields!</b>"; echo "<html> <body> <form method='post' action='contact2.php'> Name: <input type='text' name='name' id='name' value='<?php echo $_POST['name']; ?>'> <br /> <p>Email: <input type='text' name='email' /> </p> <p>Subject: <input type='text' name='subject' id='subject'> </p> <p><br /> Message:<br /> <textarea name='message' rows='15' cols='40'> </textarea> <br /> <input type='submit'/> </p> </form> </body> </html>"; } else { mail( "EMAIL", "Feedback Form Results - '$subject'", $finalmessage, "From: $email\nName:$name\n" ); header( "Location: http://www.google.com" ); } ?> Line 40, is about half way down, and contains the code <input type='text' name='name' id='name' value='<?php echo $_POST['name']; ?>'> which keeps spitting out the error message, and the line which contains the code which you jsut gave me, with the speach marks swapped, since its all in an echo statement. Can you suggest why its spitting out the error? Thanks, Lucy
  5. I am writing an email form with php validation. When a user does not enter some data into a field, and licks submit, the form returns itself, blank, with an error message at the top of the page. How can i get it so any information which was added into text fields before submit was clicked, comes back into the same text fields after the form has been submitted and found to be fields without any text in. Hope ive explained it well enough for people to understand. Code (contact.php): <?php $name = $_REQUEST['name'] ; $email = $_REQUEST['email'] ; $subject = $_REQUEST['subject'] ; $message = $_REQUEST['message'] ; $finalmessage = "This email has been sent to you from the online contact form.\n\nName: $name\nEmail: $email\nSubject: $subject\n\nMessage: ". $message; if (!isset($_REQUEST['email'])) { echo""; } elseif (empty($email) || empty($subject) || empty($message) || empty($name)) { echo "Please enter your email and message!"; } else { mail( "EMAIL", "Feedback Form Results - '$subject'", $finalmessage, "From: $email\nName:$name\n" ); header( "Location: http://www.google.com" ); } ?> <form method="post" action="contact2.php"> Name: <input type="text" name="name" id="name"> <br /> <p>Email: <input type="text" name="email" /> </p> <p>Subject: <input type="text" name="subject" id="subject"> </p> <p><br /> Message:<br /> <textarea name="message" rows="15" cols="40"> </textarea> <br /> <input type="submit" /> </p> </form> </body> </html> Thanks for any suggestions Lucy
  6. Im trying to make a contact validation form using javascript, but i cant figure out what is wrong with it. all fields are required and it works only for the top two fields, i.e. when email and name are not filled out, a popup box apears, but when the subject and message are not filled out, it does not come up with a popup box, even though ive written the code. Here is the code : <html> <head> <title>Contact Form</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <style type="text/css"> // CSS goes here </style> <script language="JavaScript"> function checkForm() { var cname, cemail, csubject, cmessage; var regex; with(window.document.msgform) { cname = sname; cemail = email; csubject = subject; cmessage = message; } if(trim(cname.value) == '') { alert('Please enter your name'); cname.focus(); return false; } else if(trim(cemail.value) == '') { alert('Please enter your email'); cemail.focus(); return false; } else if(!isEmail(trim(cemail.value))) { alert('Email address is not valid'); cemail.focus(); return false; } else if(trim(csubject.value) == '') { alert('Please enter message subject'); csubject.focus(); return false; } else if(trim(cmessage.value) == '') { alert('Please enter your message'); cmessage.focus(); return false; } else { cname.value = trim(cname.value); cemail.value = trim(cemail.value); csubject.value = trim(csubject.value); cmessage.value = trim(cmessage.value); return true; } } function trim(str) { return str.replace(/^\s+|\s+$/g,''); } </script> </head> <body> <form method="post" name="msgform"> <table width="500" border="0" align="center" cellpadding="2" cellspacing="1" class="maincell"> <tr> <td width="106">Your Name</td> <td width="381"><input name="sname" type="text" class="box" id="sname" size="30"></td> </tr> <tr> <td>Your Email</td> <td> <input name="email" type="text" class="box" id="email" size="30"> </td></tr> <tr> <td>Subject</td> <td><input name="subject" type="text" class="box" id="subject" size="30"></td> </tr> <tr> <td>Message</td> <td><textarea name="message" cols="55" rows="10" wrap="OFF" class="box" id="message"></textarea></td> </tr> <tr align="center"> <td colspan="2"><input name="send" type="submit" class="bluebox" id="send" value="Send Message" onClick="return checkForm();"></td> </tr> <tr align="center"> <td colspan="2"> </td> </tr> </table> </form> </body> </html> Thanks, Lucy
  7. I have created a header div and also a container div. I can not get them to vertically lineup in FF, i.e. they are vertically alligned but the top of the container div is not flush with the bottom of the header div. HTML code: <body> <!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>Un-named</title> <link rel="stylesheet" type="text/css" href="../layout.css" /> <link rel="stylesheet" type="text/css" href="../tabmenu.css" /> <link rel="stylesheet" type="text/css" href="../mainmenu.css" /> </head> <div id="header_container"> <ul class="tabmenu"> <li class="residential"><a href="" class="selected" title="residential"><span class="displace">Residential</span></a></li> <li class="commercial"><a href="../commercial/about.html" title="commercial"><span class="displace">Commercial</span></a></li> </ul> <ul class="mainmenu"> <li class="about"><a href="about.html" title="about"><span class="displace">About</span></a></li> <li class="survey"><a href="survey.html" title="survey"><span class="displace">Survey</span></a></li> <li class="order"><a href="order.html" title="order"><span class="displace">Order</span></a></li> <li class="track"><a href="" class="selected" title="track"><span class="displace">Track</span></a></li> <li class="contact"><a href="contact.html" title="contact"><span class="displace">Contact</span></a></li> <li class="faq"><a href="faq.html" title="faq"><span class="displace">FAQ</span></a></li> </ul> </div> <div id="content"><h1>Residential track </h1> <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur porttitor lobortis odio, at tincidunt nulla sagittis et. Donec gravida nulla sit amet purus faucibus elementum. Duis ac urna at arcu convallis dignissim at in nibh. Aliquam a molestie mi. Ut accumsan, felis vel vestibulum elementum, leo urna feugiat eros, at tincidunt lacus est eget eros. Aliquam eu nisi ultricies enim pretium interdum. Vivamus neque nulla, tempor eu bibendum eget, faucibus id dolor. Praesent venenatis enim quis neque laoreet sed sollicitudin risus pharetra. Nullam vitae mi ligula, sed porttitor lorem. Quisque mi enim, fermentum nec varius dapibus, mattis in libero. Cras volutpat velit eu libero cursus nec hendrerit urna facilisis. </p></div> <div id="footer_container">FOOTER</div> </body> </html> </body> CSS code for LAYOUT.CSS: /*Page styles*/ body { background-color:#e4e4e4; padding-left:5px; padding-right:5px; max-width:980px; margin-left:auto; margin-right:auto; } /*Header styles */ #header_container { height:200px; margin-left:auto; margin-right:auto; background-image:url(images/banner.jpg); background-repeat:no-repeat; } #header_container p { text-indent:60px; font-size:20px; } /*Main content styles */ #content { max-width:978px; top:auto; left:auto; right:auto; background-color:#FF0; margin-left:auto; margin-right:auto; } #footer_container { text-align:center; height:50px; margin-left:auto; margin-right:auto; background-color:#F00; } #footer_container ul li { margin-left:0px; padding-right:20px; padding-left:20px; display:inline; font-size:11px; } Any help would be appreciated. Thanks, Lucy
  8. I cant figure out where to put it in order to get no errors. Ive tried placing it inside the if(isset($_POST['submit'])) main set of if statements as shown here: if(isset($_POST['submit'])) { if(isset($_POST['title']) && empty($_POST['title'])){ $error['title'] = 'Please enter a title'; } if(isset($_POST['fname']) && empty($_POST['fname'])){ $error['fname'] = 'Please enter your forename'; } if(isset($_POST['sname']) && empty($_POST['sname'])){ $error['sname'] = 'Please enter your surname'; } if(isset($_POST['add1']) && empty($_POST['add1'])){ $error['add1'] = 'Please enter the first line of your address'; } if(isset($_POST['add2']) && empty($_POST['add2'])){ $error['add2'] = 'Please enter the second line of your address'; } if(isset($_POST['county']) && empty($_POST['county'])){ $error['county'] = 'Please enter your county'; } if(isset($_POST['pc']) && empty($_POST['pc'])){ $error['pc'] = 'Please enter your postcode'; } if(isset($_POST['email']) && empty($_POST['email'])){ $error['email'] = 'Please enter your email'; } if (!$error) {mysql_query("INSERT INTO customer (title, fname, sname, add1, add2, county, pc, email) VALUES ('$_POST[title]','$_POST[fname]','$_POST[sname]','$_POST[add1]','$_POST[add2]','$_POST[county]','$_POST[pc]', '$_POST[email]')") or die('Error: ' . mysql_error()); } } which works ok-ish untill i try and redirect the user to another page by using header( "Location: http://www.google.com" ); and then it comes up with the following error, just above the text boxes for input: Warning: Cannot modify header information - headers already sent by (output started at /home/sites/foo/public_html/test/newcustomer.php:12) in /home/sites/foo/public_html/test/php/testvalid.php on line 56 which corresponds directly to the statement i have just added. I cant find a suitable place to put this if statement. Any ideas? Thanks, Lucy
  9. I understand that now, thanks a lot nothing happens when all fields are valid though and the user clicks submit. How can i use the statement which i was previously using to enter data when there are no errors? it was: if ($error == 0) { mysql_query("INSERT INTO customer (title, fname, sname, add1, add2, county, pc, email) VALUES ('$_POST[title]','$_POST[fname]','$_POST[sname]','$_POST[add1]','$_POST[add2]','$_POST[county]','$_POST[pc]', '$_POST[email]')") or die('Error: ' . mysql_error()); } Thanks, Lucy
  10. Ahh right. Thanks. Il give it a bash now. Thanks, Lucy
  11. wow that looks confusing for someone who knows little about PHP like myself! How would i get the form to be submitted to itself? Thanks, Lucy
  12. that would change the colour yes, but it would not load the page with the form on, so it would simply show a red bit of text with the error, am i correct? Thanks, Lucy
  13. I dont quite understand sorry, can you ellaborate? Thanks Lucy
  14. Yes its me again! Im writing some validation for a form. The form fully validates how i would like it to but there is a slight problem about notifying the user about erroneous fields. Whenever there is an error the script just loads the form back up again via header( "Location: ../newcustomer.php" ); and changes the variable 'error' to whatever field number caused the problem. The problem is, i do not know how i can use this numeric value to change the CSS of the file so i can make the text red or something similar, on the field which caused the problem. Another problem ive just realised, is once there is a problem, and the user is sent back to the page, all of the data entered into the form has been lost. Can someone please give me some help! newcustomer.php (the main page to display the form): <body> <?php include("php/header.php"); ?> <div id="content"> <?php include("php/newcustomerform.php"); ?> </div> </body> The form itself: <form action="php/newcustomerscript.php" method="post"> <p>Title: <select name="title" id="title" tabindex="1"> <option selected="selected"></option> <option>Mr</option> <option>Mrs</option> <option>Miss</option> </select> </p> <p>Forename: <input type="text" name="fname" id="fname" tabindex="2" /> </p> <p>Surname: <input type="text" name="sname" id="sname" tabindex="3" /> </p> <p> Address line 1: <input type="text" name="add1" id="add1" tabindex="4" /> </p> <p>Address line 2: <input type="text" name="add2" id="add2" tabindex="5" /> </p> <p>County: <input type="text" name="county" id="county" tabindex="6" /> </p> <p>Postcode: <input type="text" name="pc" id="pc" tabindex="7" /> </p> <p>Email: <input type="text" name="email" id="email" tabindex="8" /> </p> <p> <input type="reset" name="clear" id="clear" value="Reset" /> <input type="submit" name="submit" id="submit" value="Submit" /> </p> <p> </p> </form> The script which validates it: <? $user="OMMITED"; //specially created username $password="OMMITED"; $database="OMMITED"; //connect to the database $con = mysql_connect("localhost",$user,$password) or die ('Could not connect: ' . mysql_error()); //select the database mysql_select_db($database, $con); // email validation function function email_valid ($email) { if (eregi("^[a-z0-9._-]+@[a-z0-9._-]+.[a-z]{2,6}$", $email)) { return TRUE; } else { return FALSE; } } //request variables from form $title = $_REQUEST['title']; $fname = $_REQUEST['fname']; $sname = $_REQUEST['sname']; $add1 = $_REQUEST['add1']; $add2 = $_REQUEST['add2']; $county = $_REQUEST['county']; $pc = $_REQUEST['pc']; $email = $_REQUEST['email']; $error = 0; if (empty($title)) { header( "Location: ../newcustomer.php" ); $error = 1; } elseif (empty($fname)) { header( "Location: ../newcustomer.php" ); $error = 2; } elseif (empty($sname)) { header( "Location: ../newcustomer.php" ); $error = 3; } elseif (empty($add1)) { header( "Location: ../newcustomer.php" ); $error = 4; } elseif (empty($add2)) { header( "Location: ../newcustomer.php" ); $error = 5; } elseif (empty($county)) { header( "Location: ../newcustomer.php" ); $error = 6; } elseif (empty($pc)) { header( "Location: ../newcustomer.php" ); $error = 7; } elseif (email_valid ($email) == FALSE) { header( "Location: ../newcustomer.php" ); $error = 8; } //insert data into database if ($error == 0) { mysql_query("INSERT INTO customer (title, fname, sname, add1, add2, county, pc, email) VALUES ('$_POST[title]','$_POST[fname]','$_POST[sname]','$_POST[add1]','$_POST[add2]','$_POST[county]','$_POST[pc]', '$_POST[email]')") or die('Error: ' . mysql_error()); } //close connection mysql_close(); ?>
  15. Thanks a lot for your help now onto validation!
  16. I have not outputted anything to the screen, it just automatically goes to a blank white screen, therefore i could use this? do i need to include the Location part i.e. header('Location:http://www.google.com/'); would be fine?
  17. How can i direct my users to a webpage once a form has been completed? I cant figure it out, i can only get it to echo text back on a white background. here is the script, which is called by the form once submit is clicked: <? $user="n-web171-sau1"; //specially created username $password="jackie01"; $database="web171-netlink"; //connect to the database $con = mysql_connect("localhost",$user,$password) or die ('Could not connect: ' . mysql_error()); //select the database mysql_select_db($database, $con); //insert data into database mysql_query("INSERT INTO customer (title, fname, sname, add1, add2, county, pc, email) VALUES ('$_POST[title]','$_POST[fname]','$_POST[sname]','$_POST[add1]','$_POST[add2]','$_POST[county]','$_POST[pc]', '$_POST[email]')") or die('Error: ' . mysql_error()); //close connection mysql_close(); ?> the form itself is a php file, which is included in the main webpage (newcustomerform.php): <form action="php/newcustomerscript.php" method="post"> <p>Title: <input type="text" name="title" tabindex="1"/> </p> <p>Forename: <input type="text" name="fname" id="fname" tabindex="2" /> </p> <p>Surname: <input type="text" name="sname" id="sname" tabindex="3" /> </p> <p> Address line 1: <input type="text" name="add1" id="add1" tabindex="4" /> </p> <p>Address line 2: <input type="text" name="add2" id="add2" tabindex="5" /> </p> <p>County: <input type="text" name="county" id="county" tabindex="6" /> </p> <p>Postcode: <input type="text" name="pc" id="pc" tabindex="7" /> </p> <p>Email: <input type="text" name="email" id="email" tabindex="8" /> </p> <p> <input type="reset" name="clear" id="clear" value="Reset" /> <input type="submit" name="submit" id="submit" value="Submit" /> </p> <p> </p> </form> and the actual webpage itself: <body> <?php include("php/header.php"); ?> <div id="content"> <?php include("php/newcustomerform.php"); ?> </div> </body> Thanks Lucy
  18. Thanks for your help, ive just fixed the problem. the missing " was a typo, sorry, my bad. the original form has the second " in. The problem was '$_POST['title']', i had put extra speech marks in the title part, where it should have only been, '$_POST[title]'. Thanks, Lucy
  19. I am trying to get a form to input data to my MYSQL database but im having a little trouble. I have created a php file called custentry.html which holds the form. I have also created another php file called custentry.php which holds the script for connecting to the database and entering the data which has been entered on the html file. Whenever i try to enter the data i get the following message: " Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/sites/foo/public_html/test/php/custentry.php on line 14 " I cant figure out what is wrong with my code. Here is the html file: <body> <form action="php/custentry.php" method="post"> <p>Title: <input type="text" name="title" /> </p> <p> <input type="reset" name="clear" id="clear" value="Reset" /> <input type="submit" name="submit" id="submit" value="Submit" /> </p> <p> </p> </form> </body> and here is the php file (with the database name and password and user taken out): <? $user="OMITTED"; //specially created username $password="OMITTED"; $database="OMITTED; //connect to the database $con = mysql_connect("localhost",$user,$password) or die ('Could not connect: ' . mysql_error()); //select the database mysql_select_db($database, $con); //insert data into database mysql_query("INSERT INTO customer VALUES ($_POST['title'])") or die('Error: ' . mysql_error()); //close connection mysql_close(); echo "entered data!"; ?> Could someone please suggest why i am getting that message? Thanks, Lucy
  20. thanks a lot that was very obvious once explained!! how can i use a style sheet in the php? can i simply do the same thing i would do to use a style sheet in a HTML file? thanks, Lucy
  21. I am trying to write a blog for a website. I have written the data entry in PHP and HTML and also have written a data retrival in PHP. The problem is, the data retrival is not formated very well, i.e. it is only text, i cant change the colour, size or anything of it in the PHP file. Could someone please advise me how i can include the php file in the HTML file and then format the output via HTML. Below is my PHP file for data retrival which has a little formatting: <? $user="n-web53-blogger"; //specially created username $password="password"; $database="web53-blog"; //connect to the database $con = mysql_connect("localhost",$user,$password) or die ('Could not connect: ' . mysql_error()); //select the database mysql_select_db($database, $con); // query to select all records and convert to result $query=mysql_query("SELECT * FROM table1"); while ($row = mysql_fetch_array($query)) { $title = $row["title"]; $date = $row["date"]; $message = $row["message"]; $author = $row["author"]; //print results echo $title."<br> "; echo $date."<br> "; echo $message."<br> "; echo $author."<br> "; echo "----------------------------------------"; echo " <br>"; } //close connection mysql_close(); ?> Please can someone help me in formatting the output via HTML Thanks, Lucy
  22. I have been given a to look after for the next year. Its written in PHP. The problem is I do not fully understand it. I fully understand HTML but not PHP. Learn PHP you may say? yes i should, and will but in the meantime I have a quick question. The index.php has links to other pages. the links are index.php?page=PAGEHERE, although I cant find any of these pages which have been linked to. I have looked throughly on the server and cant find the pages. So how would i go about changing one of the pages which I cant find? Thanks, Lucy
×
×
  • 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.