3 Replies - 3646 Views - Last Post: 25 November 2007 - 11:01 PM Rate Topic: -----

#1 allican57   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 38
  • Joined: 02-October 06

please help with PHP

Posted 23 November 2007 - 01:59 PM

I'm having trouble with saving the data entered by the user and sending an email with that data back to them. Would somebody help with these two steps? I have included the instructions only for you to get an idea of
what I'm trying to do. I want to do as much of this as I can.


Write a guestbook in PHP.
Your page should accept input from users through a form and return a message to them.
Hold all messages in a plain text file.
Your script should read the guestbook data back out of the storage file and displays it,
neatly formatted, in a new page.
Specifically, you should create an html form with a textbox for userís name,
a textarea for userís comments, one button for submitting the comments,
and another button for view all otherís comments.
You need a php file to handle two major events.
If a user clicks on the Ďsubmit the commentsí button,
the php code should write the userís name and comments to a text file.
Use fputs function to write to a file.
Also you should insert a newline after each name and each comment.
When userís name and comments are successfully recorded,
php should direct the users to a thank you page.
(You may use this code: header ("Location: thankyou.html").
On the other hand, if a user clicks on the Ďview all commentsí button,
the php code should show all users and their corresponding comments (use fgets function o).
Donít forget to format the output.
(separate name and comments in different lines and insert a blank line after each comment).


<html>
   <head>
	  <title>Guestbook</title>
   </head>
   <body>
	  <h1>Guestbook</h1>
	  
	  <form action="http://localhost/Guestbook.php" method-"POST">
	
	<table border="0">
	 <tr>
	 <td>Your Name:</td>
	 <td><input type="text" maxlength="32"  size="20"
	 name="user"></td>
	 </tr>
	  <tr>
	 <td>Your Email Address:</td>
	 <td> <input type=text name="reply-to"	
			 value="[email protected]"></td>
	 </tr>
	  <tr>
	  <td>Body:</td>
	  <td><textarea name="body" cols="25"
	   rows="7"></textarea></td>
	</tr>
	 <tr>
	  <td>&nbsp;</td>
	  <tr>
	  <td><input type="submit" value="Submit Details"></td>
	  <td><input type="reset" value="Reset The Form"></td>
	 </tr>
	 	 
	</table>
	 
  </form>
  </body>
  <html>
  
  <?php


I think the problem might be with line #8


<form action="http://localhost/Guestbook.php" method-"POST">

Thank you!

Is This A Good Question/Topic? 0
  • +

Replies To: please help with PHP

#2 snoj   User is offline

  • Married Life
  • member icon

Reputation: 93
  • View blog
  • Posts: 3,583
  • Joined: 31-March 03

Re: please help with PHP

Posted 23 November 2007 - 02:40 PM

If that be all, you're using a - instead of an =.
Was This Post Helpful? 0
  • +
  • -

#3 allican57   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 38
  • Joined: 02-October 06

Re: please help with PHP

Posted 24 November 2007 - 10:16 AM

View Postsnoj, on 23 Nov, 2007 - 02:40 PM, said:

If that be all, you're using a - instead of an =.


Thanks, Good catch. we're off to a good start. I'm still having a problem getting the PHP started, and getting an email back to user could you just get me started with it ? (Corrected code below) I'm not asking for code, just an idea to get started. Thanks again

<html>
   <head>
	  <title>Guestbook</title>
   </head>
   <body>
	  <h1>Guestbook</h1>
	  
	  <form action="http://localhost/Guestbook.html" method="POST">
	
	<table border="0">
	 <tr>
	 <td>Your Name:</td>
	 <td><input type="text" maxlength="32"  size="20"
	 name="user"></td>
	 </tr>
	  <tr>
	 <td>Your Email Address:</td>
	 <td><input type="text" maxlength="32"  size="20"
	 name="mail"></td>
	 </tr>
	  <tr>
	  <td>Body:</td>
	  <td><input type="text"cols="25" rows="7"
	 name="body" ></td>
	</tr>
	 <tr>
	  <td>&nbsp;</td>
	  <tr>
	  <td><input type="submit" value="Send Email" name="submit"></td>
	  <td><input type="button" value="View All Comments"></td>
	 </tr>
	</table>
	 
  </form>
  </body>
  <html>
 
  <?PHP 

Was This Post Helpful? 0
  • +
  • -

#4 nav33n   User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 71
  • Joined: 02-October 07

Re: please help with PHP

Posted 25 November 2007 - 11:01 PM

Quote

I'm still having a problem getting the PHP started, and getting an email back to user could you just get me started with it ?


http://in2.php.net/m...nction.mail.php
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1