0% found this document useful (0 votes)
4 views3 pages

Doctype HTML

The document is a PHP script that handles a form submission for user profile data, including name, email, website, comments, and gender. It connects to a MySQL database and inserts the submitted data into a 'profile' table upon form submission. The script also includes basic error handling for database connection issues.

Uploaded by

Alfred Gumapac
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views3 pages

Doctype HTML

The document is a PHP script that handles a form submission for user profile data, including name, email, website, comments, and gender. It connects to a MySQL database and inserts the submitted data into a 'profile' table upon form submission. The script also includes basic error handling for database connection issues.

Uploaded by

Alfred Gumapac
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

<!

DOCTYPE HTML>

<html>

<head>

</head>

<body>

<?php

include('db.php');

if ($_SERVER["REQUEST_METHOD"] == "POST"){

$name=$_POST["name"];

$email=$_POST["email"];

$website=$_POST["website"];

$connect=$_POST["connect"];

$gender=$_POST["gender"];

if ($_SERVER["REQUEST_METHOD"]== "POST"){

$sql = "insert into profile (name,email,website,connect,gender) values


('$name','$email','$website','$connect','$gender')";

if (mysqli_query($conn,$sql)){

echo "<br> Record created successfully";

?>

<h2>PHP Fom Validation Example</h2>

<form method="POST" action="<?php echo htmlspecialchars ($_SERVER["PHP_SELF"]) ;?>">

Name: <input type="text" name="name" >

<br><br>

E-mail: <input type="text" name="email">

<br><br>

Website: <input type="text" name="website">


<br><br>

Comment: <textarea name="connect" rows="5" cols="40"></textarea>

<br><br>

Gender: <input type="radio" name="gender" value=" female">

Female <input type="radio" name="gender" value="'male">

Male <input type="radio" name="gender" value="other">Other

<br><br>

<input type="submit" name="submit" value=" Submit"> </form> </body> </htm?>

</form>

</body>

</html>
<?php

$server ="localhost";

$user= "root";

$pw ="";

$db ="rz";

$conn = mysqli_connect($server,$user,$pw,$db);

if ($conn===false){

die ("error:we are not connected to each other".mysqli_connect_error());

?>

You might also like