Sei sulla pagina 1di 6

Reg.

No : 50410104020

PHP with MYSQL Install php using the following command # yum install php Install Apache using the command #yum install httpd To start or stop the Apache server use the command #/etc/init.d/httpd start #/etc/init.d/httpd stop Type the php program and save the file with the extension .php To enter into mysql connection use mysql u root p. To create a database use create database database_name; . And then create a table with the required fields. Move the programs to the location /var/www/html/ If the access permission is denied then change the access permission of the file using the command chmod 777 file_name . Output can be viewed in the web browser by entering the url http://localhost/filename.php

Program :

REGISTRATION FORM USING PHP AND MYSQL

STEPS TO CREATE THE DATABASE :

Open the terminal Change to super user using the command SU and enter the password To access or open mysql give the command mysql Now create a database in the name stud use the command create database stud After creating the database , create a user to access the mysql from the apache server by giving the command create user admin@localhost identified by admin123; . In order to grant access to the created user ( admin ) to access the database file use the command grant all on stud.* to admin; .

Reg. No : 50410104020

To see the created database use the command show databases;

Reg. No : 50410104020

Now quit mysql using the command quit

use the command mysql u admin h loccalhost p and enter into the mysql by giving the password. use show databases; to check that the database has been created.

Reg. No : 50410104020

Use the command use stud to use the created stud database Then create the table in the name student with the required fields

FORM.PHP
<html> <head> <title>Sign up Form</title> </head> <center> <form name="signup" method="post" action="connect.php"> Reg No.:<input type="text" name="reg"/><br /> Name:<input type="text" name="name"/><br /> emailid:<input type="text" name="email"/><br /> phoneno:<input type="text" name="ph"/><br /> <input type="submit" value="submit" /> </form> </center> </html>

Reg. No : 50410104020 CONNECT.PHP <?php $con=mysql_connect('localhost','admin','admin123'); mysql_select_db("stud",$con); $sql="INSERT INTO student(reg,name,email,ph) values ('$_POST[reg]','$_POST[name]','$_POST[email]','$_POST[ph]')"; mysql_query($sql,$con); echo"successfully added"; ?> Output :

Open the browser and open the php file by entering the following in the address bar http://localhost/form.php

After enter the details in the fields click on submit. If the datas are entered successfully then the connect.php file will be opened.

Reg. No : 50410104020

Now go back to the terminal and use the command select * from student; to check data entered into the database.

Potrebbero piacerti anche