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 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...
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,...
PHP Question: Subject: Managing Persistence. Objective: • Create a login script. • Strengthen passwords. • Authenticate...
PHP Question: Subject: Managing Persistence. Objective: • Create a login script. • Strengthen passwords. • Authenticate users. • Create sessions. • Create cookies. • Manage persistence. Description: All dynamic sites need a way to manage access to resources. Many dynamic sites use back-end databases that can contain sensitive information that needs to be securely managed. At the same time, sites want to be inviting to guests. Managing the access to sensitive information is a critical function. Requirements: Update site for...
The name of your bash script must be script1 and below is a description of what...
The name of your bash script must be script1 and below is a description of what it should do when executed. The script displays a message Guess, what is zip program's location Then it displays a message Enter the full path e.g. /etc/zip or /proc/bus/zip Then it reads the users response If the user's response is correct, it displays a message Great guess, zip's location is XXX, where XXX is the correct location of zip , and the script terminates....
⦁   Write a Bash script that prompts for user input and reads a string of text...
⦁   Write a Bash script that prompts for user input and reads a string of text from the user. If the user enters a no null (no empty) string, the script should prompt the user to re-enter again the string; otherwise should display the string entered “. ⦁   Given an array of the following four integers (3, 5, 13, 14); write a Bash script to display the second and all elements in the array.    ⦁   Write a short Bas...
Q.3 . Products A, B, and C are produced from a single raw material input. The...
Q.3 . Products A, B, and C are produced from a single raw material input. The raw  mat-          erial and other production costs up to the split-off point are $100,000, from which          10,000 units of Product A, 15,000 units of Product B, and 10,000 units of Product C          can be produced each period.          At split-off point, selling prices are as follows:               - Product A $2 per unit               - Product B $3 per unit               - Product C $5 per unit.         The Company...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT