Question

In: Computer Science

Q 3 b) In this question you must write a php script to take Name[input =...

Q 3 b)

In this question you must write a php script to take Name[input = text], Country[input = select, card_number[input = number], and type of card[input = radio button]to get user's input. The name of this file will be payment.php.

Once the user submits the form; you must direct all the information to cust_info.html.

The task is to keep a record in the cust_info.html of all the users who fill the forms and hit submit.

the output must populate the list in the form of;

Tiger Woods; CA;123456789123545698; VISA

Lucky Mann; FL; 2365415698712365478; MASTER CARD

...............................................

..............................................

up to six forms of info.

Alert: you can only use  PHP and HTML. NO JavaScript or database [20 points]

Solutions

Expert Solution

files:  cust_info.html (it will be edited by php , create a blank file with this name)

Payment.php

<?php 
  //echo("hhhh");
  if (isset($_POST['submit'])) { 
      //Saving data into a file named cust_info.html
    $myfile = fopen("cust_info.html", "a") or die("Unable to open file!");
    $file_data=$_POST['Name'].";".$_POST['Country'].";".$_POST['card_number'].";".$_POST['type_of_card']."<br>\n";
      $file_data .= file_get_contents('cust_info.html');
    file_put_contents('cust_info.html', $file_data);
  //  fwrite($myfile, $data1);
    fclose($myfile);
    header("Location: cust_info.html"); 

  } 
  ?> 


<!DOCTYPE html>
<html>

<body>

<h3>Enter Payment Information</h3>

<div>
  <form action="<?php echo $_SERVER['PHP_SELF'];?>" method=post>
    <label for="name">First Name</label>
    <input type="text" id="name" name="Name" placeholder="Your name.." required>

    <label for="country">Country</label>
    <select id="country" name="Country">
      <option value="au">Australia</option>
      <option value="ca">Canada</option>
      <option value="usa">USA</option>
      <option value="In">India</option>
    </select>
  
    <label for="cnum">Card number</label>
    <input type="number" id="cnum" name="card_number" placeholder="" required>
     
     <p>Type of Card</p>
    <input type="radio" id="master" name="type_of_card" value="MASTER CARD" required>
    <label for="master">Master Card</label><br>
    <input type="radio" id="visa" name="type_of_card" value="VISA" checked>
    <label for="visa">VISA</label><br>


    <input type="submit" value="submit" name="submit">
  </form>
</div>







<style>
input[type=text], select,input[type=number] {
  width: 100%;
  padding: 12px 20px;
  margin: 8px 0;
  display: inline-block;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-sizing: border-box;
}

input[type=submit] {
  width: 100%;
  background-color: #4CAF50;
  color: white;
  padding: 14px 20px;
  margin: 8px 0;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

input[type=submit]:hover {
  background-color: #45a049;
}

div {
  border-radius: 5px;
  background-color: #f2f2f2;
  padding: 20px;
}
</style>
</body>
</html>


Related Solutions

Write a Python script that takes an input image and output's the name of the dominant...
Write a Python script that takes an input image and output's the name of the dominant color in that image(i.e. red, green, blue).  
Task 2.5: Write a script that will ask the user for to input a file name...
Task 2.5: Write a script that will ask the user for to input a file name and then create the file and echo to the screen that the file name inputted had been created 1. Open a new file script creafile.sh using vi editor # vi creafile.sh 2. Type the following lines #!/bin/bash echo ‘enter a file name: ‘ read FILENAME touch $FILENAME echo “$FILENAME has been created” 3. Add the execute permission 4. Run the script #./creafile.sh 5. Enter...
Write a brief shell script that will take in a specific file name, prompt the user...
Write a brief shell script that will take in a specific file name, prompt the user whether they would like to gzip, bzip2, or xz compress the file. Depending on response, the script then ought to compress the provided file with the corresponding method
Write a simple PHP script. In your script use all of the following: HTML, Javascript, and...
Write a simple PHP script. In your script use all of the following: HTML, Javascript, and PHP.
Write a program in Java that will take as input two sets A and B, and...
Write a program in Java that will take as input two sets A and B, and returns a list of all functions from A to B.
Write a bash script that will allow you to: Read in your Your name Course name...
Write a bash script that will allow you to: Read in your Your name Course name and Instructor’s name Then prompt the user to enter two numbers and determine which number is greater. Ex: If 10 is entered for the first number and 3 for the second, you should output Your name Course name Instructor’s name 10 is greater than 3. If 33 is entered for the first number and 100 for the second, you shou output Your name Course...
Write a PHP script to display in frequency all the words in the submitted paragraph. Convert...
Write a PHP script to display in frequency all the words in the submitted paragraph. Convert the string to an array of words. Count the number of times the words are used. Hint: array_count_values($arrayname) Sort the array in frequency order. Print the array to the screen. Hint: print_r($arrayname)
JAVA script! You will write a program that will input the nationalities of your favorite types...
JAVA script! You will write a program that will input the nationalities of your favorite types of food, examples, and prices of some of your favorite food. You will save a type of food, two examples of that type of food, the price of each of those two examples, and a total price of both together. You must input your own types, examples, and prices, but check a sample run below. You must use the concepts and statements that we...
PHP Question: Write the PHP code to list out all of the dates of the current...
PHP Question: Write the PHP code to list out all of the dates of the current month and assign them to their given days. As an example, for the month of October 2020, the output should look something like this: October 2020       Monday: 5, 12, 19, 26 Tuesday: 6, 13, 20, 27 Wednesday: 7, 14, 21, 28 Thursday: 1, 8, 15, 22, 29 Friday: 2, 9, 16, 23, 30 Saturday: 3, 10, 17, 24, 31 Sunday: 4, 11, 18,...
Write a PHP script that: 1) Has an associative array with 10 student names and test...
Write a PHP script that: 1) Has an associative array with 10 student names and test scores (0 to 100). ie. $test_scores('John' => 95, ... ); 2)Write a function to find the Average of an array. Input is an array, output is the average. Test to make sure an array is inputted. Use ARRAY_SUM and COUNT. 3)Output the test scores highest to lowest, print scores above the average in Green. Find a PHP Sort function for associative arrays, high to...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT