Learnt PHP at last

Learning PHP when it was presented as a part of MCA syllabus was a tough ask for me , but asking to do a simple web page using PHP and HTML with just in a few hours of time is further more difficult .This was the case when my friend asked me to do the same (a simple Registration page ) for the Gateways 2008 ( Inter- college IT fest conducted by PG Dept. of Computer Science , Christ College – Bangalore ) and that too in a short span of time but to an extend was successful in understanding how it works and did it . This was done solely from the Code lifted from one of My lecturer ( Mr. Ashok immanuel ) and some changes made by us for the same.This involved not using MYSql but just Files….

The Code for the same is done using 3 files as stated below….

1. Reg.html – a html file for the interface

Gateways style=”width: 1000px; height: 165px” />
Gateways 2008 College Registration
College Name
College Address
Contact Person
Contact Email
Phone Number

2. a1.php – This files contains some of the PHP code to write in to the mail and send a mail

$flag=0;
$college_name = 0;
$college_address = 0;
$contact_person = 0;
$contact_email = 0;
$contact_phone = 0;
$nl=”,”;
$n2=”\n”;
if($_POST['collegename']==” ”)
return false;
else
$flag=1;
$college_name=$_POST['collegename'];
$college_address=$_POST['collegeaddress'];
$contact_person=$_POST['contactperson'];
$contact_email=$_POST['contactemail'];
$contact_phone=$_POST['contactphone'];
$str=$n2. $college_name .$nl. $college_address .$nl. $contact_person .$nl. $contact_email .$nl. $contact_phone . “     ” ;
$fp = fopen(”data.txt”, “a+”);
fwrite($fp,$str);
fclose($fp);
$to=”gateways@mca.christuniversity.in“;
$subject=”Registration of ” . $college_name ;
$message = “College Name : ”. $college_name .”
 College Address : ”. $college_address .”
 Contact Person : ”. $contact_person .”
 Contact Email : ”. $contact_email .”
 Contact Phone : ” . $contact_phone . “     ” ;
$headers = ‘From: ‘. $contact_email;
$headers .= “\r\nContent-Type: text/html;charset=iso-8859-1\r\nContent-Transfer-Encoding: 7bit”;
$msg=” ”;
if(@mail( $to, $subject, $message, $headers ))
{
�
$msg = ” Registration Request Sent Successfully”;
echo $msg;                             �
}
$_POST['collegename']=” “;
$_POST['collegeaddress']=” “;
$_POST['contactperson']=” “;
$_POST['contactemail']=” “;
$_POST['contactphone']=” “;
?>

3. data.txt – a text files to store all the registration details

Thats it my work was done with in a day.

Share