Question: What's wrong with the code? The code can be seen below the submit button on the page Registration Form Rasmussen Registration Form Fill in your
What's wrong with the code? The code can be seen below the submit button on the page
Registration Form
Rasmussen Registration Form
Fill in your name and telephone, then click Submit to register.
FIRST_NAME LAST_NAME TELEPHONE
// DB connection info // Within the PHP tags, add PHP code for connecting to the database. $host = " us-cdbr-azure-central-a.cloudapp.net "; $user = "b207b67c4c62ac"; $pwd = "b8db6089"; $db = "cda";
// Connect to Database. try { $conn = new PDO( "mysql:host=$host;dbname=$db", $user, $pwd); $conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); } catch(Exception $e){ die(var_dump($e)); } //Following the database connection code, add code for inserting registration information into the database. if(!empty($_POST)) { try { $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $telephone = $_POST['telephone']; // Insert data $sql_insert = "INSERT INTO test (FIRST_NAME, LAST_NAME, TELEPHONE) VALUES (?,?,?)"; $stmt = $conn->prepare($sql_insert); $stmt->bindValue(1, $first_name); $stmt->bindValue(2, $last_name); $stmt->bindValue(3, $telephone); $stmt->execute(); } catch(Exception $e) { die(var_dump($e)); } echo "
You're Registered!
"; } //Finally, following the code above, add code for retrieving data from the database. $sql_select = "SELECT * FROM test"; $stmt = $conn->query($sql_select); $registrants = $stmt->fetchAll(); if(count($registrants) > 0) { echo "
People Who Are Registered:
"; echo ""; echo ""; echo ""; echo ""; foreach($registrants as $registrant) { echo ""; echo ""; echo ""; } echo "
| FIRST_NAME | LAST_NAME | TELEPHONE |
|---|---|---|
| ".$registrant['FIRST_NAME']." | ".$registrant['LAST_NAME']." | ".$registrant['TELEPHONE']." |
"; } else { echo "
No one is currently registered.
"; }
?>
This is a block paragraph #2
This is a block paragraph #3
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
