Learnt PHP at last

Your 2020 Plan. Learn 20 minutes a day for 20 days. Online courses from €9.99.

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

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", "+");
fwrite($fp,$str);
fclose($fp);
$to="[email protected]";
$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.

One thought on “Learnt PHP at last

  1. You need to use backslash before special charachters in order for them to be shown here, at the moment your HTML code for registration part1 is unreadable.

    Also instead of using a text file you could use an XML file, It would make it a bit easier to work with.

Leave a Reply

Your email address will not be published. Required fields are marked *