Please Read! php problem.

Thread Solved

Join Date: Jan 2009
Posts: 1,373
Reputation: almostbob has a spectacular aura about almostbob has a spectacular aura about almostbob has a spectacular aura about 
Solved Threads: 166
almostbob's Avatar
almostbob almostbob is offline Offline
Nearly a Posting Virtuoso

Re: Please Read! php problem.

 
0
  #11
Sep 14th, 2009
php forms can be self processing, its easy to debug one script, try
  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
  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.
Failure is not an option It's included free, you don't have to do anything to get it
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it

Please mark solved problems, solved
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 77
Reputation: ivatanako is an unknown quantity at this point 
Solved Threads: 5
ivatanako ivatanako is offline Offline
Junior Poster in Training

Re: Please Read! php problem.

 
0
  #12
Sep 14th, 2009
Originally Posted by JerieLsky View Post
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:

  1. <?php
  2. echo "Me.";
  3. ?>

what do u think is causing the problem?
can you post the whole code?
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 1,373
Reputation: almostbob has a spectacular aura about almostbob has a spectacular aura about almostbob has a spectacular aura about 
Solved Threads: 166
almostbob's Avatar
almostbob almostbob is offline Offline
Nearly a Posting Virtuoso

Re: Please Read! php problem.

 
0
  #13
Sep 14th, 2009
this is a better line16
  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.
Failure is not an option It's included free, you don't have to do anything to get it
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it

Please mark solved problems, solved
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 73
Reputation: smartness is an unknown quantity at this point 
Solved Threads: 10
smartness's Avatar
smartness smartness is offline Offline
Junior Poster in Training

Re: Please Read! php problem.

 
0
  #14
Sep 14th, 2009
try this:
  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!
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 41
Reputation: JerieLsky is an unknown quantity at this point 
Solved Threads: 0
JerieLsky JerieLsky is offline Offline
Light Poster

Re: Please Read! php problem.

 
0
  #15
Sep 14th, 2009
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:

  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.
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 41
Reputation: JerieLsky is an unknown quantity at this point 
Solved Threads: 0
JerieLsky JerieLsky is offline Offline
Light Poster

Re: Please Read! php problem.

 
0
  #16
Sep 14th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 77
Reputation: ivatanako is an unknown quantity at this point 
Solved Threads: 5
ivatanako ivatanako is offline Offline
Junior Poster in Training

Re: Please Read! php problem.

 
1
  #17
Sep 14th, 2009
Originally Posted by JerieLsky View Post
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
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 1,373
Reputation: almostbob has a spectacular aura about almostbob has a spectacular aura about almostbob has a spectacular aura about 
Solved Threads: 166
almostbob's Avatar
almostbob almostbob is offline Offline
Nearly a Posting Virtuoso

Re: Please Read! php problem.

 
1
  #18
Sep 14th, 2009
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.
Failure is not an option It's included free, you don't have to do anything to get it
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it

Please mark solved problems, solved
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 77
Reputation: ivatanako is an unknown quantity at this point 
Solved Threads: 5
ivatanako ivatanako is offline Offline
Junior Poster in Training

Re: Please Read! php problem.

 
0
  #19
Sep 14th, 2009
if it still does work, try starting your wamp server
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 41
Reputation: JerieLsky is an unknown quantity at this point 
Solved Threads: 0
JerieLsky JerieLsky is offline Offline
Light Poster

Re: Please Read! php problem.

 
0
  #20
Sep 14th, 2009
Whew!! I guess that solves the problem. Well thanks guys, you we're of great help add up more reputations to you guys..
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC