Jump to content

jackie11

Members
  • Posts

    51
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

jackie11's Achievements

Member

Member (2/5)

0

Reputation

  1. Thats great it works a treat, thank you all for all your help!!! Jackie :) :) :) :) :) :) :) :)
  2. Hi I have changed the code to: [code]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head>   <title>Employee Index</title> </head> <body> <h1 style="text-align: center;"><img src="etc/Logo_pic_1.JPG"></h1> <hr style="width: 100%; height: 2px;"> <?php $user="root"; $host="localhost"; $password=""; $database = "employee_index"; mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("employee_index") or die(mysql_error()); if (isset($_POST['Surname'])) { $errors = array(); if(empty($_POST['Office_location'])){echo "The Office Location field is empty, try again!<br>\n";} if(empty($_POST['Expertise'])){echo "The Expertise field is empty, try again!<br>\n";} if(empty($_POST['Hobbies'])){echo "The Hobbies field is empty, try again! <br>\n";} if(empty($_POST['Surname'])){echo "Surname field is empty, try again! <br>\n";} if(empty($_POST['Forename'])){echo "Forename field is empty, try again! <br>\n";} if(empty($_POST['Job_title'])){echo "Job Title field is empty, try again! <br>\n";} if(empty($_POST['DOB'])){echo "DOB field is empty, try again!<br>\n";} if(empty($_POST['Telephone'])){echo "Telephone field is empty, try again!<br>\n";} if(empty($_POST['Email'])){echo "Email field is empty, try again!<br><br>\n";} if (!preg_match('|^[a-z]+$|i', $_POST['Surname'])) $errors[] = "Surname can contain only letters!"; if (!preg_match('|^[a-z]+$|i', $_POST['Forename'])) $errors[] = "Forename can contain only letters!"; if (!preg_match('|^[0-9]+$|', $_POST['Telephone'])) $errors[] = "Telephone can contain only digits!"; if (!preg_match('|^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$|i', $_POST['Email'])) $errors[] = "You must provide a valid email address!"; if (!preg_match('|^[0-9]+$|', $_POST['Office_location'])) $errors[] = "Office Location contain only digits!";   if (count($errors) > 1) { $msg = "<p class=\"error\">The following errors have occurred: " . implode('<br />', $errors) . "</p>\n"; echo $msg; } else { $imagename = basename($_FILES['Picture']['name']); $sqlquery = "INSERT INTO employee (Surname, Forename, Job_title, Office_location, Telephone, Email, Expertise, Hobbies, DOB, Picture) VALUES ('$_POST[Surname]','$_POST[Forename]','$_POST[Job_title]','$_POST[Office_location]','$_POST[Telephone]','$_POST[Email]', '$_POST[Expertise]','$_POST[Hobbies]','$_POST[DOB]','$imagename')"; $result = mysql_query($sqlquery) or die (mysql_error()); print "<html><body><center>"; print "<p><B>Thank You - You have just entered the following information successfully!</B><p>"; print "Surname : $_POST[Surname]<br>"; print "Forename : $_POST[Forename]<br>"; print "Job Titile : $_POST[Job_title] <br>"; print "Office Location : $_POST[Office_location]<br>"; print "Telephone : $_POST[Telephone] <br>"; print "Email :$_POST[Email] <br>"; print "Expertise : $_POST[Expertise]<br>"; print "Hobbies : $_POST[Hobbies] <br>"; print "DOB : $_POST[DOB]<br>"; print "</body></html>"; $target_path = "../test_2/pics/"; $target_path = $target_path . basename( $_FILES['Picture']['name']); if(move_uploaded_file($_FILES['Picture']['tmp_name'], $target_path)) {     echo "The file ".  basename( $_FILES['Picture']['name']).     " has been uploaded"; } else {     echo "There was an error uploading your picture file, please try again!"; } } mysql_close(); ?> <hr style="width: 100%; height: 2px;"> <p style="text-align: center;"><a href="index.html"><img style="border: 0px solid ; width: 94px; height: 47px;" alt="Home" src="etc/Home_button.JPG"></a></p> <hr style="width: 100%; height: 2px;"> </body> </html> [/code] but I am now getting the error message: Parse error: parse error, unexpected $end in C:\Program Files\xampp\htdocs\test_2\script_1.php on line 105 Any suggestions??? Jackie
  3. Thanks for the replies, however the if statements and validations themselves work ok as I have used them in another form, the problem I am having is linking them with inserting the info into the db, i.e. - if errors are detected display error message and no info is inserted into db or - if no errors detected insert info into db and display print ststaements of what has been inserted any suggestions? Jackie
  4. Hi everyone I am looking for a little help getting my my form to validate and insert info into my db, I am first trying to validate a form submitted by a user, if an error is found, error messages are displayed If no errors are found it prints what info they have sucessfully added to the db everything works until I add in the validation script then everything goes pear shaped can anyone have a look at my script and see where I am going wrong It would be most appriciated Jackie [code]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head>   <title>Employee Index</title> </head> <body> <h1 style="text-align: center;"><img src="etc/Logo_pic_1.JPG"></h1> <hr style="width: 100%; height: 2px;"> <?php $user="root"; $host="localhost"; $password=""; $database = "employee_index"; mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("employee_index") or die(mysql_error()); if (isset($_POST['Surname'])) { $errors = array(); if(empty($_POST['Office_location'])){echo "The Office Location field is empty, try again!<br>\n";} if(empty($_POST['Expertise'])){echo "The Expertise field is empty, try again!<br>\n";} if(empty($_POST['Hobbies'])){echo "The Hobbies field is empty, try again! <br>\n";} if(empty($_POST['Surname'])){echo "Surname field is empty, try again! <br>\n";} if(empty($_POST['Forename'])){echo "Forename field is empty, try again! <br>\n";} if(empty($_POST['Job_title'])){echo "Job Title field is empty, try again! <br>\n";} if(empty($_POST['DOB'])){echo "DOB field is empty, try again!<br>\n";} if(empty($_POST['Telephone'])){echo "Telephone field is empty, try again!<br>\n";} if(empty($_POST['Email'])){echo "Email field is empty, try again!<br><br>\n";} if (!preg_match('|^[a-z]+$|i', $_POST['Surname'])) $errors[] = "Surname can contain only letters!"; if (!preg_match('|^[a-z]+$|i', $_POST['Forename'])) $errors[] = "Forename can contain only letters!"; if (!preg_match('|^[0-9]+$|', $_POST['Telephone'])) $errors[] = "Telephone can contain only digits!"; if (!preg_match('|^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$|i', $_POST['Email'])) $errors[] = "You must provide a valid email address!"; if (!preg_match('|^[0-9]+$|', $_POST['Office_location'])) $errors[] = "Office Location contain only digits!";   if (count($errors) < 1) {   } else { $msg = "<p class=\"error\">The following errors have occurred: " . implode('<br />', $errors) . "</p>\n";   } } echo isset($msg) ? $msg : ''; } else { $imagename = basename($_FILES['Picture']['name']); $sqlquery = "INSERT INTO employee (Surname, Forename, Job_title, Office_location, Telephone, Email, Expertise, Hobbies, DOB, Picture) VALUES ('$_POST[Surname]','$_POST[Forename]','$_POST[Job_title]','$_POST[Office_location]','$_POST[Telephone]','$_POST[Email]', '$_POST[Expertise]','$_POST[Hobbies]','$_POST[DOB]','$imagename')"; $result = mysql_query($sqlquery) or die (mysql_error()); print "<html><body><center>"; print "<p><B>Thank You - You have just entered the following information successfully!</B><p>"; print "Surname : $_POST[Surname]<br>"; print "Forename : $_POST[Forename]<br>"; print "Job Titile : $_POST[Job_title] <br>"; print "Office Location : $_POST[Office_location]<br>"; print "Telephone : $_POST[Telephone] <br>"; print "Email :$_POST[Email] <br>"; print "Expertise : $_POST[Expertise]<br>"; print "Hobbies : $_POST[Hobbies] <br>"; print "DOB : $_POST[DOB]<br>"; print "</body></html>"; $target_path = "../test_2/pics/"; $target_path = $target_path . basename( $_FILES['Picture']['name']); if(move_uploaded_file($_FILES['Picture']['tmp_name'], $target_path)) {     echo "The file ".  basename( $_FILES['Picture']['name']).     " has been uploaded"; } else{     echo "There was an error uploading your picture file, please try again!"; } } mysql_close(); ?> <hr style="width: 100%; height: 2px;"> <p style="text-align: center;"><a href="index.html"><img style="border: 0px solid ; width: 94px; height: 47px;" alt="Home" src="etc/Home_button.JPG"></a></p> <hr style="width: 100%; height: 2px;"> </body> </html> [/code]
  5. Hi Works a treat, cheers! :) :) :) :) Jackie
  6. Hi I have set up a search for my db, which searches the surname of people held on the db. It works ok, but the only problem I am having is that if there is more than one person woith the same surname it only displays one of them, how can I go about tellling it to display all results it has found My code is: [code] <html> <head><title>Employee Index</title></head> <body> <h1><img src="etc/Logo_pic_2.JPG"></h1> <?php $search = $_POST["search"];   mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("employee_index") or die(mysql_error());   $query = "SELECT * FROM employee WHERE Surname = '$search'";   $result = mysql_query ($query)or die(mysql_error());     if (!mysql_num_rows($result)) { print "<p><BR><B>Sorry no results found - please try again!</BR> </p>" ; exit; } else { while ($row = mysql_fetch_array($result)) { extract($row);   $Employee_ID = $row['Employee_ID']; $Surname = $row['Surname']; $Forename = $row['Forename']; $Job_title = $row['Job_title']; $Office_location = $row['Office_location']; $Telephone = $row['Telephone']; $Email = $row['Email']; $Expertise = $row['Expertise']; $Hobbies = $row['Hobbies']; $DOB = $row['DOB']; $Picture = "<a href='../test_2/pics/" . $row['Picture'] . "' border='0'><img src='../test_2/pics/" . $row['Picture'] . "' border='0' width='90' height='100'></a>";          } } echo "<table cellspacing='15'>";   echo "<tr><td colspan='20'><hr></td></tr>";   echo "<th>ID</th><th>Picture</th><th>Surname</th><th>Forename</th><th>Job Title</th>   <th>Office Location</th><th>Telephone</th>   <th>Email</th><th>Expertise</th><th>Hobbies</th><th>DOB</th>";   echo "<tr><td colspan='20'><hr></td></tr>";       echo "           <td>$Employee_ID</td>\n           <td>$Picture</td>\n           <td>$Surname</td>\n             <td>$Forename</td>\n             <td>$Job_title</td>\n               <td>$Office_location</td>\n               <td>$Telephone</td>\n                 <td>$Email</td>\n                 <td>$Expertise</td>\n                   <td>$Hobbies</td>\n                   <td>$DOB</td>\n                               </tr>\n";     echo "<tr><td colspan='20'><hr></td></tr>\n";   echo "</table>\n";   ?> <p style="text-align: left;"> <a href="index.html"> <img style="border: 0px solid ; width: 94px; height: 47px;" alt="Home" src="etc/Home_button.JPG"></a></p> </span></span> </body> </html> [/code] Thanks Jackie :-\
  7. Hi That sounds like exactly what I need but I not sure how to do it, I have tried to look up a way to set this up but can't seem to find one, could anyone point me in te right direction! Thanks Jackie
  8. Hi Thanks that has worked great, the only thing is, is there any way that if an error is detected then you will be redirected to another page with the results displayed on that page, because at the moment the errors display at the top of the page and the table with blank fields appear below it? Any suggestions Regards Jackie
  9. Hi everyone I have been trying to create some simple form validation but what I have created does not seem to be working, no error messages are dispalying and it just dispalys the page enven if he fields are not entered correctly any suggestions? Thanks Jackie [code]<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head>   <title>form_display.php</title>   <link rel="stylesheet" href="etc/TJConsultants.css"> </head> <body> <br> <div id="wrapper"> <div id="header"> <div style="text-align: center;"><br> </div> <br> </div> <div id="centercolumn"> <div style="text-align: center;"><br> </div> <div style="text-align: center;"> <hr style="width: 100%; height: 2px;"><font style="color: rgb(21, 27, 84);" size="+3">Employee Details<br> </font> <hr style="width: 100%; height: 2px;"><font style="color: rgb(21, 27, 84);" size="+3"> </font> <?php if (isset($_POST['submit'])) { $errors = array(); if (!preg_match('|^[a z]+$|i', $_POST['Surname'])) $errors[] = "Surname can contain only letters!"; if(empty($_POST['Surname'])){echo "username is empty";} if (!preg_match('|^[a z]+$|i', $_POST['Forename'])) $errors[] = "Forename can contain only letters!"; if (!preg_match('|^[0-9]+$|', $_POST['Office_location'])) $errors[] = "Office Location contain only digits!"; if (!preg_match('|^[0-9]+$|', $_POST['Telephone'])) $errors[] = "Telephone can contain only digits!"; if (!preg_match('|^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$|i', $_POST['Email'])) $errors[] = "You must provide a valid email address!"; if (!preg_match('|^[0-9]+$|', $_POST['DOB'])) $errors[] = "DOB must  contain only digits!";   if (count($errors) < 1) {   } else { $msg = "<p class=\"error\">The following errors have occurred: " . implode('<br />', $errors) . "</p>\n";   } } echo isset($msg) ? $msg : ''; ?> <?php $Employee_ID = $_POST['Employee_ID']; $Surname = $_POST['Surname']; $Forename = $_POST['Forename']; $Job_title = $_POST['Job_title']; $Office_location = $_POST['Office_location']; $Telephone = $_POST['Telephone']; $Email = $_POST['Email']; $Expertise = $_POST['Expertise']; $Hobbies = $_POST['Hobbies']; $DOB = $_POST['DOB']; $target_path = "../page_g/etc/"; $target_path = $target_path . basename( $_FILES['Picture']['name']); if(move_uploaded_file($_FILES['Picture']['tmp_name'], $target_path)) {echo ""; } else{     echo "There was an error uploading your picture file, please try again!"; }     ?> <table align="center" cellspacing="15">   <tbody>     <tr> <td style="text-align: center";>       <img src= "<?php echo $target_path; ?> "picture="" border="0" height="100" width="90"></a></td> <td style="text-align: center;"></td>     </tr>   </tbody> </table> <br>     <table style="text-align: left; margin-left: auto; margin-right: auto; width: 490px; height: 495px;" border="1" cellpadding="2" cellspacing="2">   <tbody>     <tr>       <td width="25%" style=" text-align: left; vertical-align: middle; font-family: Tahoma; color: rgb(0, 0, 102);">Employee ID:</td>       <td width="75%"><?php echo $Employee_ID ?></td>     </tr>     <tr>       <td style="font-family: Tahoma; color: rgb(0, 0, 102);">Surname:</td>       <td width="75%"><?php echo $Surname ?></td>     </tr>       <tr>       <td style="font-family: Tahoma; color: rgb(0, 0, 102);">Forename:</td>         <td width="75%"><?php echo $Forename ?></td>     </tr>     <tr>       <td style="font-family: Tahoma; color: rgb(0, 0, 102);">Job Title:</td>     <td width="75%"><?php echo $Job_title ?></td>     </tr>     <tr>     <td style="font-family: Tahoma; color: rgb(0, 0, 102);">DOB:</td> <td width="75%":=""><?php echo $DOB ?></td>     </tr>     <tr>       <td style="font-family: Tahoma; color: rgb(0, 0, 102);">Telephone:</td>       <td width="75%":=""><?php echo $Telephone ?></td>     </tr>         <tr>       <td style="font-family: Tahoma; color: rgb(0, 0, 102);">Email:</td>       <td width="75%"><?php echo $Email ?></td>     </tr>   <tr>       <td style="font-family: Tahoma; color: rgb(0, 0, 102);">Office Location:</td>       <td width="75%"><?php echo $Office_location ?></td>     </tr>         <tr>       <td style="font-family: Tahoma; color: rgb(0, 0, 102);">Expertise:</td>       <td width="75%"><?php echo $Expertise ?></td>     </tr> <tr>       <td style="font-family: Tahoma; color: rgb(0, 0, 102);">Hobbies:</td>       <td width="75%"><?php echo $Hobbies ?></td> </tr>       </tbody> </table> <BR> <hr style="width: 100%; height: 2px;"> <br> <div style="text-align: left;"><a href="index.html"><img style="border: 0px solid ; width: 94px; height: 46px;" alt="Home" src="etc/Home_button.JPG"></a><br> <hr style="width: 100%; height: 2px;"> </div> </div> </div> <div id="footer"> <p style="text-align: left;"></p> </div> </div> </body> </html> [/code]
  10. Hi Thanks that works great! Jackie
  11. Hi all I was trying to get a picture uploaded from a form and then to display in a table, which I finally managed to get working perfectly, but I have made a change (by accident) to the code that displays the picture and now the picture will not display and I can't manage to get it working again, really can't fingure out what I have done, its probably something really simple, I have tried re-arranging the code a number of different ways but I can't remember how I had it set up previously, (it really does teach me that I should make a back-up copy when things are working) Any suggestions Thanks Jackie [code] <?php $Employee_ID = $_POST['Employee_ID']; $Surname = $_POST['Surname']; $Forename = $_POST['Forename']; $Job_title = $_POST['Job_title']; $Office_location = $_POST['Office_location']; $Telephone = $_POST['Telephone']; $Email = $_POST['Email']; $Expertise = $_POST['Expertise']; $Hobbies = $_POST['Hobbies']; $DOB = $_POST['DOB']; $target_path = "../page_g/etc/"; $target_path = $target_path . basename( $_FILES['Picture']['name']); if(move_uploaded_file($_FILES['Picture']['tmp_name'], $target_path)) {echo ""; } else{     echo "There was an error uploading your picture file, please try again!"; }         ?> <table align="center" cellspacing="15">   <tbody>     <tr> <td style="text-align: center"; <a href='../page_g/etc/{$target_path['basename']}' border='0'>       <img src= <?php echo= $target_path ?> picture="" border="0" height="100" width="90"></a></td> <td style="text-align: center;"></td>     </tr>   </tbody> </table> [/code]
  12. I still can't get this to work, I think its a problem with upload as after using the following code I get the message that "There was an error uploading your picture file, please try again!" Any suggestions? [code]<?php $Employee_ID = $_GET['Employee_ID']; $Surname = $_GET['Surname']; $Forename = $_GET['Forename']; $Job_title = $_GET['Job_title']; $Office_location = $_GET['Office_location']; $Telephone = $_GET['Telephone']; $Email = $_GET['Email']; $Expertise = $_GET['Expertise']; $Hobbies = $_GET['Hobbies']; $DOB = $_GET['DOB']; $target_path = "../page_g/pics/"; $target_path = $target_path . basename( $_FILES['Picture']['name']); if(move_uploaded_file($_FILES['Picture']['tmp_name'], $target_path)) {echo "The file ".  basename( $_FILES['Picture']['name']).     " has been uploaded"; } else{     echo "There was an error uploading your picture file, please try again!"; }   $Picture = basename($_FILES['Picture']['name']);           ?> [/code]
  13. Hi Yes sorry my code is all over the place because I have been trying a number of things out, I know I need to define $Picture but am not sure how to do this after I have used the $_FILE, and copied the file from the temporary folder, is it something like: [code]<?php $Employee_ID = $_GET['Employee_ID']; $Surname = $_GET['Surname']; $Forename = $_GET['Forename']; $Job_title = $_GET['Job_title']; $Office_location = $_GET['Office_location']; $Telephone = $_GET['Telephone']; $Email = $_GET['Email']; $Expertise = $_GET['Expertise']; $Hobbies = $_GET['Hobbies']; $DOB = $_GET['DOB']; move_uploaded_file ($_FILES['Picture'] ['tmp_name'],       "../uploads/{$_FILES['Picture'] ['name']}")       $picture= $_FILES ['Picture'];             ?> [/code] Jackie
  14. Hi can anyone help with this, I have been working away on it but can't seem to get anything to work properly! Jackie
×
×
  • 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.