Jump to content

Patwan

Members
  • Posts

    34
  • Joined

  • Last visited

Patwan's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. I have understood the concept, thank-you once more for your patience...
  2. Also do you guys have an offline version of W3Schools website? cause am in a remote area in Africa & accessing the internet can be a real hurdle
  3. I've looked around for a few examples and followed the tutorials here but a lot of them are either too advanced for my grasp of PHP as abeginner or their examples are too specific to their own projects. Here's my new snippet // Check Checkbox if(!empty($_POST["checkbox"])){ $checkbox = $_POST['checkbox']; foreach ($_POST["checkbox"] as $value) //loop to store and display values of individual checkboxes {echo "$value"; } else{$checkbox= test_input($_POST["$value"]);}}
  4. // Check Checkbox if(!empty($_POST["checkbox"])){ $checkbox = array("HP", "DELL", "ACER", "TOSHIBA"); foreach ($checkbox as $value) { echo "$checkbox"; } else { $checkbox = test_input($_POST["checkbox"]);} } Followed the tutorial. But still can't get it post the values in my inbox..
  5. <?php if ($_SERVER["REQUEST_METHOD"] == "POST") { // Check Checkbox if(!empty($_POST["checkbox"])){ $value=false; foreach($_POST["checkbox"] as $selected) foreach ["HP", "DELL", "ACER", "TOSHIBA"]; $checkboxErr = "Please Select one of these options"; } else { $checkbox = test_input($_POST["checkbox"]);} } ?> How about that? Am not sure of it,,Could you explain using an example so as to follow easily
  6. Or could you Please explain using the code above as an example..?
  7. This way <?php if ($_SERVER["REQUEST_METHOD"] == "POST") { // Check Checkbox if(!empty($_POST["checkbox"])){ $value=false; foreach($_POST["checkbox"]) $checkboxErr = "Please Select one of these options"; } else { $checkbox = test_input($_POST["checkbox"]);} $array = ["HP", "DELL", "ACER", "TOSHIBA"]; } ?>
  8. Hello dsonesuk, was trying to code a multiple checkbox array for the form above. Cant figure out the problem in the code below? Kindly assist.. HTML code Which type of laptop would you like us to deliver to you? <span class= "error"> * </span> <br> <br> <input type="checkbox" class="input" name="checkbox[]" value="HP"> H.P <br> <input type="checkbox" class="input" name="checkbox[]" value="DELL" > DELL <br> <input type="checkbox" class="input" name="checkbox[]" value="ACER" > ACER<br> <input type="checkbox" class="input" name="checkbox[]" value="TOSHIBA" > TOSHIBA PHP code <?php if ($_SERVER["REQUEST_METHOD"] == "POST") { // Check Checkbox if(!empty($_POST["checkbox"])){ $checkboxErr = "Please Select one of these options"; } else { $checkbox = test_input($_POST["checkbox"]);} $array = ["HP", "DELL", "ACER", "TOSHIBA"]; } ?>
  9. Duly noted,, thanks for your help
  10. Wow..Thanks, I have understood & It works fine, Does the same criteria apply to checkboxes?
  11. Could you Kindly explain using example from the code above so that I can understand easily?
  12. I only want the user to select one option from the Drop-down list, not multiple options. Do i Still need an array?
  13. Hi all, I have a HTML contact form on my website whereby when the user hits submit button I get all other inputs in my email except option from Drop-down list. What could be the problem? ~ Kindly assist <?php //initialize variables and set to empty values $name = $phone = $email = $business = $industry= ""; $nameErr = $phoneErr = $emailErr = $businessErr = $industryErr=""; ini_set('display_errors', 1); error_reporting(E_ALL); if ($_SERVER["REQUEST_METHOD"] == "POST") { $valid = true; //check if name contains letters and white-space if (empty($_POST["name"])) { $valid = false; $nameErr = "Please fill out this field"; echo 'name is empty<br>'; } else { $name = test_input($_POST["name"]); if (!preg_match("/^[a-zA-Z ,.-]*$/", $name)) { $valid = false; $nameErr = "*Only Letters and white-spaces are allowed*"; } /* else { echo'name is valid<br>'; } */ } //check if phone contains numbers if (empty($_POST["phone"])) { $valid = false; $phoneErr = "Please fill out this field"; echo'phone is empty<br>'; } else { $phone = test_input($_POST["phone"]); if (!preg_match("/^[0-9 ,+.-]*$/", $phone)) { $valid = false; $phoneErr = "*Only numbers are allowed*"; } /* else { echo' phone is valid<br>'; } */ } //check if email is valid if (empty($_POST["email"])) { $valid = false; $emailErr = "Please fill out this field"; echo'email is empty<br>'; } else { $email = test_input($_POST["email"]); if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $valid = false; $emailErr = "*Invalid email address*"; } /* else { echo'email is valid<br>'; } */ } //check if industry is filled if (empty($_POST["industry"])) { $industryErr = "Please Select an item"; } else {$industry = test_input($_POST["industry"]);} } ?> <!DOCTYPE html> <html> <head> <meta name= "robots" content= "noindex, nofollow"> <meta charset="UTF-8"> <meta name= "author" content= "Kelly James"> <link href= "style.css" rel= "stylesheet" type= "text/css"> <title> Contact form </title> </head> <body> <img src= "images/logo.gif" border= "0" width= "240" height="160"> <br> <div class="form"> <form method= "post" action= "<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" > <h4 id="h4form"> Please fill the form below to kick start your project. <br> <br> <font color="red"> *required field </font> </h4> <br> What is your name? <input type= "text" class= "input" name= "name" placeholder= "e.g Nelson Mandela" value="<?php echo $name; ?>" required> <span class= "error"> * <br> <?php echo $nameErr; ?> </span> <br> <br>What is your phone number? <input type= "text" class= "input" name= "phone" value="<?php echo $phone; ?>" placeholder= "e.g 0722222222" required> <span class= "error"> * <br> <?php echo $phoneErr; ?> </span> <br> <br> What is your email address? <input type= "email" class= "input" name= "email" placeholder= "will not be published" value="<?php echo $email; ?>" required> <span class= "error"> * <br> <?php echo $emailErr; ?> </span> <br> <br> What industry is your business? <span class= "error"> * <?php echo $industryErr;?> </span> <select class= "input" name="industry" required> <option value= "" > Select Industry </option> <option value= "Air_and_Travel" >Air & Travel </option> <option value= "Agriculture">Agriculture</option> <option value= "Architecture and Structural"> Architecture and Structural </option> <option value="Attorney & legal"> Attorney & Legal </option> <option value="Automotive"> Automotive </option> <option value= "Consultation"> Consultation </option> </select> <br> <br> <button class="submit" type= "submit" value= "Submit"> Submit Form </button> </form> </div> </body> </html>
  14. Duly noted, I'll put that into consideration
  15. Do you guys have a tutorial in W3schools of "How to send an auto-responder email to a client"?
×
×
  • Create New...