Jump to content
xisto Community
Sign in to follow this  
NeOniX

Contacting Sheet With Php And No Db

Recommended Posts

Well, that microtutorial explains how to set up a simple system of using a form data, and use it to do a decent contact sheet in webs that the user needs to tell the webmaster its impression of the web, or for reclamations, or whatever you can imagine. :)

 

Only will be needed of 3 files:

 

- 1 html/php file containing the form

- 1 php file for processing the form data

- 1 html/txt file for output

 

Additionally, I recommend to give to the output file a hard to imagine name, cuz it's supposed you dont wanna let everybody to read it :D.

 

Well, imagine your WebServer is at C:\Web\, well, you could embed the form and processing pages into your existing pages, but you also could name the formpage as form.php, the processing page as form2.php, and finally the output file as output_contact_form.html (I highly recommend to use html pages for output).

 

OK, lets start, you have to do a form into the form.html page, and set the name of the fields, etc.

i.e.: (3 fields is OK for contact sheets: Name, Mail, and the text, and is nice to include the client IP first if you're going to save it, if the page was PHP)

<html>  <body>	<form method="post" action="form2.php">	  <p>Your name<input type="text" name="name"></p>	  <p>Your e-mail<input type="text" name="mail"></p>	  <p>Text to send<input type="text" name="text"></p>	  <p>Logged IP: <? echo $_SERVER['REMOTE_ADDR'] ?>	  <p><input type="submit" value="Go!"></p>	</form>  </body></html>

Then the processing page (it will write to the output file, without caring if all the fields were filled out, only will ste the blank field to "not filled")

<html><body><?$file=fopen('output_contact_form.html','a'); /*'a' stands for read/write permission, moving the cursor to the last character, so it will look nice cuz it will look like a list of Reports */$ip=$_SERVER['REMOTE_ADDR'];$date=date('H:i:s m-d-Y'); // the date in PHP format, if you wanna include itif (!$_POST['name']) {	$name='not filled';}else{ $name=$_POST['name'];}if (!$_POST['mail']) {$mail='not filled';}else{$mail=$_POST['mail'];}if (!$_POST['text']) {$text='not filled';}else{$text=$_POST['text'];}// under this lines, you can set the format for the output, i'll put a lil example$text_to_output='<br><font size="3" face="Verdana, Arial" color="#000000"><hr><br><p><b>'.$name.'</b> <font size="2">('.$mail.', '.$ip.', '.$date.')</p><p>'.$text.'<br><br>';// then, we put it into the file...fputs($file,$text_to_output);// ...and echo a Sent Msgecho '<br><p align="left">Message Sent.</p>';?>

That should work :(, only look at the output_contact_form.html

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.