Jump to content

Aldayne_Henry

Members
  • Posts

    16
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Aldayne_Henry's Achievements

Member

Member (2/5)

0

Reputation

  1. sorry for the late reply @barand my internet is so shakey where i am at now. I want to ensure that the user enters the format for academic year example( 2020/21 ). But when i used the code below it allows for even letters into the mix as well and without brackets as well. How would i go about ensuring the user uses the format (2020/21) ... brackets included if(!empty($_POST ['ay'])) { if(!preg_match(" ([0-9/])",$_POST['ay'])) { $formerrors [] = ' " Incorrect format for academic year " '; } }
  2. i have another issue.. @Barand i want to retain the post form data in the form fields so when there is an error it still keeps the data the user entered in the field.. is there anyway you can assist with that?
  3. <?php session_start(); if($_SERVER['REQUEST_METHOD'] == 'POST') { $post2= array_map('trim', $_POST); $verrors = []; if($post2['address'] == '') { $verrors= ' " Please enter a street address" '; } if($post2['district'] == '') { $verrors= ' "Please enter a district" '; } if($post2['parish'] == '') { $verrors= ' "Please enter a city or parish" '; } if($post2['country'] == '') { $verrors= ' "Please enter a country" '; } if($post2['email'] == '') { $verrors= ' "Please enter an email" '; } if($post2['tele'] == '') { $verrors= ' "Please enter a telephone number" '; } if(!empty($post2['address'])) { if(!preg_match("/^[a-z0-9- ]+$/i", $post2['address'])) { $verrors= ' "Enter a valid address number" '; } } if(!empty($post2['district'])) { if(!preg_match("([a-zA-Z' ])",$post2['district'])) { $verrors= ' "Invalid district" '; } } if(!empty($post2['parish'])) { if(!preg_match("([a-zA-Z' ])",$post2['parish'])) { $verrors= ' "Invalid parish" '; } } if(!empty($post2['country'])) { if(!preg_match(" ([a-zA-Z' ])", $post2['country'])) { $verrors= ' "Invalid country" '; } } if(!empty($post2['email'])) { if(!fliter_var($post2['email'], FILTER_VALIDATE_EMAIL)) { $verrors= ' "This is an invalid email address" '; } } if(!empty($post2['tele'])) { if(!is_numeric($post2['tele'])) { $verrors= ' "You entered a invalid phone number with text or characters please do not enter" '; } } if(!empty($post2['tele'])) { if(strlen($post2['tele']) > 7) { $verrors= ' "You entered a telephone number greater than 7 digits" '; } else if(strlen($post2['tele']) < 7) { $verrors= ' "You entered a phone number less than 7 digits" '; } } if($verrors) { $post2['verrors']= $verrors; $qstr2= http_build_query($post2); header("Location:addpatientform2.php?$qstr2"); exit; } header("Location:welcome.php"); } ?> does the problem with the join have anything to do with my validation page? @Barand because i am looking all over and im not finding the error that may be causing this predicament
  4. yes cause on my validation page i did $post['errors']= $errors and then on my form page i did if(isset($_GET['errors']) && !empty($_GET['errors'])) so i dont know why it is not working for this page because it worked for the other
  5. <?php session_start(); ?> <!DOCTYPE html> <html> <head> <title> Medical Login Page </title> <link rel="stylesheet" type="text/css" href="Registrationcss2.css"> </head> <body background="testtube.jpg"> <?php if (isset($_GET['errors']) && !empty($_GET['errors']) ) { echo "<div style='padding:16px; background-color: red; color: white'>".join('<br>', $_GET['errors'])."</div>"; } ?> <div id="login.wrapper"> <div class="container"> </div> <form action="validateregistrationpage2.php" method="POST" id="login"> <center><h2>MEDICAL PATIENT REGISTRATION FORM</h2></center> <label> Street Address </label> <input type= "text" name="address" placeholder="Enter patient's street address"/> <label> District </label> <input type= "text" name="district" placeholder="Enter patient's District" > <label> Parish/City </label> <input type= "text" name="parish" placeholder="Enter patient's parish" > <label> Country </label> <input type= "text" name="country" placeholder="Enter patient's country of origin" > <label> Email </label> <input type= "text" name= "email" placeholder="Enter patient email address in form of (alexbrown@gmail.com)"> <label> Telephone number </label> <input type= "text" name= "tele" placeholder="Enter patient telephone number in form of (555-555-555)"> <button type="submit" name="submitform" id="submit"> Submit Form</button> </form> </div> </body> </html> i have another issue, the join function is now misbehaving.. it now gives me an error saying invalid arguements yet i did this for my other page and it worked perfectly. what is going on?
  6. @Barand sorry for being so bothersome.. i just need help with displaying the data from the seperate pages on one page.. is that possible? if so how do i go about it
  7. i have one more issue @Barand, how would i then output the data from the first page and the second page? i would want them to be displayed together on another page. is that possible?
  8. <?php session_start(); if($_SERVER['REQUEST_METHOD'] == 'POST') { $post= array_map('trim', $_POST); $errors = []; if ($post['firstname']== '') { $errors[] = "<p>Please enter the patient first name</p>" ; } if($post['lastname'] == '') { $errors[]= "<p>Please enter a last name</p>" ; } if($post['dateofbirth'] == '') { $errors[]= "<p>Please select a date of birth</p>" ; } if($post['trn'] == '') { $errors[] = "<p>Please Enter a trn</p>" ; } if($errors) { $post['errors']= $errors; $qstr= http_build_query($post); header("Location:addpatientform.php?$qstr"); exit; } header("Location:addpatientform2.php"); } ?> so i tried it your way @Barand but the errors do not show in the form itself it shows in the url bar.. i want the errors to show up in the form
  9. This is the form code <?php session_start(); $firstn=""; $lastn=""; $dateofbirth= ""; $title=""; $TRN= ""; $firstnameerror=""; $lastnameerror=""; $trnerror=null; $doberror=""; $titleerror=""; ?> <!DOCTYPE html> <html> <head> <title> Medical Login Page </title> <link rel="stylesheet" type="text/css" href="Registrationcss.css"> </head> <body background="testtube.jpg"> <div id="login.wrapper"> <div class="container"> </div> <form action="validateregistrationpage.php" method="POST" id="login"> <center><h2>MEDICAL PATIENT REGISTRATION FORM</h2></center> <label> Title </label> <select name= "title" placeholder= "--------" value= " <?php echo $title;?>"> <option value="mr" value=""> Mr. </option> <option value= "mrs" value = "" > Mrs. </option> <option value= "sir" value= " "> Sir. </option> <option value= "miss" value= " "> Miss. </option> </select><br><br> <label> First Name </label> <input type= "text" name="firstname" placeholder="Enter patient's first name" value="<?php echo $firstn; ?>"/> <?php if(isset($firstnameerror)) { ?> <?php echo $firstnameerror ?> <?php } ?> <label> Last Name </label> <input type= "text" name="lastname" placeholder="Enter patient's last name" value="<?php echo $lastn; ?>"> <label> Date of Birth </label> <input type= "date" name="dateofbirth" placeholder="select patient's date of birth" value= "<?php echo $dateofbirth; ?>" > <label> TRN </label> <input type= "text" name="trn" placeholder="Enter patient's 9 digit TRN" value= "<?php echo $TRN; ?>" > <br><br> <button type="submit" name="next" id="submit"> Next</button> </form> </div> </body> </html>
  10. 1. What do you mean i should check the post method request? 2. trim the post array? 3. kill the script after header redirect? //This is the php code <?php session_start(); if(isset($_POST['next'])) { $firstn=$_POST['firstname']; $lastn=$_POST['lastname']; $dateofbirth= $_POST['dateofbirth']; $title=$_POST['title']; $TRN= $_POST['trn']; $firstnameerror=""; $lastnameerror=""; $trnerror=null; $doberror=""; $titleerror=""; $_SESSION['errorflag'] = 0; if(empty($_POST['firstname'])) { $firstnameerror= "<p style= 'color:red'> First name is required </p>"; header("Location: addpatientform.php"); } else { $firstn=$_POST['firstname']; } if(empty($_POST['lastname'])) { $lastnameerror= "<p style= 'color:red'> Last name is required </p>"; header("Location: addpatientform.php"); } else { $lastn= $_POST['lastname']; } if(preg_match("([a-zA-Z'])",$firstn)) { echo 'valid first name given'; } else { $firstnameerror= "invalid first name given"; } if(preg_match("([a-zA-Z'])",$lastn)) { echo 'valid last name given'; } else { $lastnamerror= "invalid last name"; header("Location: addpatientform.php"); } if(empty($_POST['dateofbirth'])) { $doberror= "<p style= 'color:red'> Date of birth is required please enter date of birth </p>"; header("Location: addpatientform.php"); } else { $dateofbirth=$_POST['dateofbirth']; } if(empty($_POST['trn'])) { $trnerror= "<p style= 'color:red'> TRN IS REQUIRED </p>"; header("Location: addpatientform.php"); } else { $TRN=$_POST['trn']; } if(!filter_var($TRN, FILTER_VALIDATE_INT)) { $trnerror= "<p style= 'color:red> Incorrect TRN format </p>"; header("Location: addpatientform.php"); } if(strlen($TRN) > 9 || strlen($TRN) < 9) { $trnerror= "<p style= 'color:red> <TRN LENGTH IS NOT 10 DIGITS </p>"; header("Location: addpatientform.php"); } } ?>
×
×
  • 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.