php and HTML Create a form and corresponding database to be used to obtain infor
ID: 3726901 • Letter: P
Question
php and HTML
Create a form and corresponding database to be used to obtain information from each student at the university and will ask about water services, electricity services, internet services, other needs. It will include name, address, email, and phone number. It will also ask the student to indicate if he or she would like to receive support from the university and indicate various types of support: economic, academic, counseling, other with text field to include textual information about this.
Explanation / Answer
As per your requirement the below one is solution please follow it
// HTMl and PHP Section of Form
Name: <input type="text" name="name" value="<?php echo $name;?>">
Address: <input type="text" name="address" value="<?php echo $address;?>">
E-mail: <input type="text" name="email" value="<?php echo $email;?>">
Phone Number: <input type="text" name="phone" value="<?php echo $phone;?>">
Support Required: <textarea name="comment" rows="5" cols="40"><?php echo $support;?></textarea>
<input type="submit" name="submit" value="Submit!">
// DataBase Section
<?php
// Provide below information as per your credentials
$host = 'localhost:3036';
$user = 'root';
$pass = 'rootpassword';
$conntn = mysql_conntnect($host, $user, $pass);
if(! $conntn ) {
die('Could not conntnect: ' . mysql_error());
}
echo 'conntnected successfully';
$sql = 'CREATE TABLE employee( '.
'name VARCHAR(20) NOT NULL, '.
'address VARCHAR(20) NOT NULL, '.
'email VARCHAR(40) NOT NULL, '.
'phone VARCHAR(40) NOT NULL, '.
mysql_select_db('test_db');
$retval = mysql_query( $sql, $conntn );
if(! $retval ) {
die('Could not create table: ' . mysql_error());
}
echo "Table employee created successfully ";
mysql_close($conntn);
?>
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.