943,909 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 1378
  • PHP RSS
You are currently viewing page 2 of this multi-page discussion thread; Jump to the first page
Sep 14th, 2009
0

Re: Please Read! php problem.

php forms can be self processing, its easy to debug one script, try
php Syntax (Toggle Plain Text)
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <!-- @(#) $Id$ -->
  4. <head>
  5. <title>HTML Template</title>
  6. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
  7. </head>
  8. <body>
  9. <?php if (isset($_POST["submit"])) {
  10. if(!$_POST['name'] || !$_POST['email'] || !$_POST['question'] )
  11. { echo "Required fields not completed, please input the required fields."; }
  12. else { $name = $_POST['name'];
  13. $email = $_POST['email'];
  14. $question = $_POST['question'];
  15. $message = wordwrap("Message from $name \n Message: $question", 70);
  16. if(!mail($email,"Inquiry",$message)) {echo "Sending failed, please input the required fields."; } else echo "Message sent.";
  17. } } ?>
  18. <form name='FAQ' method='post' action='<?php echo $_SERVER["PHP_SELF"]; ?>'>
  19. <table cellpadding='0' cellspacing='5' border='0' width='500' align='center'>
  20. <tr>
  21. <td width='150'><p class='content'>Name: * </td>
  22. <td width='350'><input type='text' size='55' name='name'></td>
  23. </tr>
  24. <tr>
  25. <td width='150'><p class='content'>Email Address: * </td>
  26. <td width='350'><input type='text' size='55' name='email'></td>
  27. </tr>
  28. <tr>
  29. <td width='150'><p class='content'>Question: * </td>
  30. </tr>
  31. <tr>
  32. <td width='350' colspan='2'><textarea cols='59' rows='5' name='question'></textarea></td>
  33. </tr>
  34. <tr>
  35. <td colspan='2' align='right'><input type='submit' value='Submit' name='submit'></td>
  36. </tr>
  37. </table>
  38. </form>
  39. </body>
  40. </html>
but the message is only being sent to the sender, no address is specified for you
Try replacing line 16
php Syntax (Toggle Plain Text)
  1. if(!mail('myaddress@mysite.com',"Inquiry",$message,"Cc:$email\r\n")) {echo "Sending failed, please input the required fields."; } else echo "Message sent.";
message to "customer service", copy to sender
all necessary html headers are sent before any script output, in case malformed pages are being thrown out by the server,
Last edited by almostbob; Sep 14th, 2009 at 11:15 am.
Reputation Points: 562
Solved Threads: 368
Posting Maven
almostbob is offline Offline
2,970 posts
since Jan 2009
Sep 14th, 2009
0

Re: Please Read! php problem.

Click to Expand / Collapse  Quote originally posted by JerieLsky ...
this is what i did in the .php file, i omitted the contents and i just replaced it with this statement but still no output:

PHP Syntax (Toggle Plain Text)
  1. <?php
  2. echo "Me.";
  3. ?>

what do u think is causing the problem?
can you post the whole code?
Reputation Points: 18
Solved Threads: 15
Junior Poster
ivatanako is offline Offline
150 posts
since Jul 2007
Sep 14th, 2009
0

Re: Please Read! php problem.

this is a better line16
php Syntax (Toggle Plain Text)
  1. if(!mail('me@mysite.com',"Inquiry","$message","From: $email " . "\r\n" . "Cc: $email"."\r\n")) {echo "Sending failed,"; } else { echo "Message sent."; }
Last edited by almostbob; Sep 14th, 2009 at 12:36 pm.
Reputation Points: 562
Solved Threads: 368
Posting Maven
almostbob is offline Offline
2,970 posts
since Jan 2009
Sep 14th, 2009
0

Re: Please Read! php problem.

try this:
PHP Syntax (Toggle Plain Text)
  1. <?php
  2. //The button is presed
  3. if (isset($_POST["submit"]))
  4. {
  5. $name = $_POST['name'];
  6. $email = $_POST['email'];
  7. $question = $_POST['question'];
  8. $message = "Message from $name \n Message: $question";
  9.  
  10. $sent_mail = mail($email,$message,$message);
  11. if($sent_mail) {
  12. echo "Message sent.";
  13. die();//Stop here
  14. } else {
  15. "Message was NOT Sent.";
  16. die();
  17. }
  18. }
  19. else {
  20. ?>
  21. <table cellpadding="0" cellspacing="5" border="0" width="500" align="center">
  22. <form name="FAQ" method="post" action="mail.php">
  23.  
  24. <tr>
  25. <td width="150"><p class="content">Name: * </td>
  26. <td width="350"><input type="text" size="55" name="name"></td>
  27. </tr>
  28. <tr>
  29. <td width="150"><p class="content">Email Address: * </td>
  30. <td width="350"><input type="text" size="55" name="email"></td>
  31. </tr>
  32. <tr>
  33. <td width="150"><p class="content">Question: * </td>
  34. </tr>
  35. <tr>
  36. <td width="350" colspan="2"><textarea name="question" cols="59" rows="5"></textarea></td>
  37. </tr>
  38. <tr>
  39. <td colspan="2" align="right"><input type="submit" value="Submit" name="submit"></td>
  40. </tr>
  41. <tr>
  42. <td>&nbsp;</td>
  43. </tr>
  44. </form>
  45. </table>
  46.  
  47. <?php
  48. }
  49. ?>

This worked on my server. Tested!
Reputation Points: 7
Solved Threads: 14
Junior Poster
smartness is offline Offline
103 posts
since Aug 2007
Sep 14th, 2009
0

Re: Please Read! php problem.

Hi there almostbob, thanks for the quick response.. well actually i'm still having a problem with one line that you've give which is in line 18 stating:

PHP Syntax (Toggle Plain Text)
  1. <form name='FAQ' method='post' action='<?php echo $_SERVER["PHP_SELF"]; ?>'>

The problem is in the action='<?php echo $_SERVER["PHP_SELF"]; ?>'
Once that i click the Submit button a "Page Load Error" occurs saying

"Firefox can't find the file at /C:/Documents and Settings/rEd_xiii21/Desktop/programming/ERDI Website Final/Duplicate of Edited Site/<?php echo $_SERVER["PHP_SELF"]; ?>."

What does the code - action='<?php echo $_SERVER["PHP_SELF"]; ?>' - actually do?

Thanks for your time.
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
JerieLsky is offline Offline
63 posts
since Jul 2009
Sep 14th, 2009
0

Re: Please Read! php problem.

Here is a link to download the .html and .php file that i'm working with.

http://www.adrive.com/public/c510468...5e82f624c.html

Ahm, i'm actuallly using wamp server, I've set them ONLINE and started all services too.. so I think I don't have a problem with it though.
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
JerieLsky is offline Offline
63 posts
since Jul 2009
Sep 14th, 2009
1

Re: Please Read! php problem.

Click to Expand / Collapse  Quote originally posted by JerieLsky ...
Here is a link to download the .html and .php file that i'm working with.

http://www.adrive.com/public/c510468...5e82f624c.html

Ahm, i'm actuallly using wamp server, I've set them ONLINE and started all services too.. so I think I don't have a problem with it though.
I can assure that the code that this guys have given are all working. Your code even works, it prints "ME" after i click the submit button.

Have you put your files in the WWW directory?? in wamp by default, it is located here C:\wamp\www\

then try accessing it like this

http://localhost/E-FAQ.html
Reputation Points: 18
Solved Threads: 15
Junior Poster
ivatanako is offline Offline
150 posts
since Jul 2007
Sep 14th, 2009
1

Re: Please Read! php problem.

you are trying to run php from the local file system /C:/Documents and Settings/rEd_xiii21/Desktop/programming/ERDI Website Final/Duplicate of Edited Site/
that wont work, even if it is the same folder
php has to run as http://127.0.0.1/filepath/filename.php (or localhost/)
move all the files you wish to work on, below the folder assigned as localhost in your php/wamp/IDE settings and access them though the localhost url
I do not know what php system version/wamp/ide you have installed but the errors now seem to be simply method problems, but a solution is getting closer (nervous fingers crossed)
Last edited by almostbob; Sep 14th, 2009 at 11:07 pm.
Reputation Points: 562
Solved Threads: 368
Posting Maven
almostbob is offline Offline
2,970 posts
since Jan 2009
Sep 14th, 2009
0

Re: Please Read! php problem.

if it still does work, try starting your wamp server
Reputation Points: 18
Solved Threads: 15
Junior Poster
ivatanako is offline Offline
150 posts
since Jul 2007
Sep 14th, 2009
0

Re: Please Read! php problem.

Whew!! I guess that solves the problem. Well thanks guys, you we're of great help add up more reputations to you guys..
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
JerieLsky is offline Offline
63 posts
since Jul 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: echo google problem
Next Thread in PHP Forum Timeline: php Error: 403 Forbidden





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC