0% found this document useful (0 votes)
16 views2 pages

Conectivity With PHP

Uploaded by

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

Conectivity With PHP

Uploaded by

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

Name : Connect.

php

<?php include 'FormData.php'; ?>

<?php

// create a variable

$fname=$_POST['first_name'];

$lname=$_POST['last_name'];

$marks=$_POST[‘marks’];

$selected_course = $_POST['Course'];

//Execute the query

$connect = mysql_connect("localhost","root","");

if (!$connect)

die('Could not connect: ' . mysql_error());

mysql_select_db("college",$connect);

$sql="INSERT INTO bcca(fname,lname,course) VALUES


(‘$fname’,'$lname','$selected_course')";

if(!mysql_query($sql,$connect))

die('Error'. mysql_error());

echo "Student Added";

mysql_close($connect);

# echo mysqli_error ($connect);?>


Name: FormData.php

<html><head><style>

label{display:inline-block;width:100px;margin-bottom:10px;}

</style><title>Add Student</title>

</head><body>

<form method="post" action="Connect.php">

<label>First Name </label>

<input type="text" name="first_name"/>

<br />

<label>Last Name</label>

<input type="text" name="last_name"/>

<br />

<label>Marks</label>

<input type="text" name="marks"/>

<br />

<select name="course">

<option value="BCCA">BCCA</option>

<option value="BCA">BCA</option>

<option value="BCOM">BCOM</option>

<option value="BBA">BBA</option>

<option value="MCA">MCA</option>

</select><input type="submit"></form></body></html>

You might also like