Please Read! php problem.

Please support our PHP advertiser: 50% off 6 Months Dedicated Server Hosting from 1&1!
Thread Solved

Join Date: Jul 2009
Posts: 43
Reputation: JerieLsky is an unknown quantity at this point 
Solved Threads: 0
JerieLsky JerieLsky is offline Offline
Light Poster

Please Read! php problem.

 
0
  #1
Sep 14th, 2009
I'm just new in php actually and this is the problem that i have been encountering lately. I actually have one .html file and .php file, on the .html file I created a form which looks like this:
  1. <table cellpadding="0" cellspacing="5" border="0" width="500" align="center">
  2. <form name="FAQ" method="post" action="question.php">
  3. <span style="font-family: Arial, Helvetica, sans-serif;font-size: 12px;font-style: normal;line-height: normal;font-weight: normal;font-variant: normal;text-transform: none;color: #000000;">
  4. <tr>
  5. <td width="150"><p class="content">Name: * </td>
  6. <td width="350"><input type="text" size="55" name="name"></td>
  7. </tr>
  8. <tr>
  9. <td width="150"><p class="content">Email Address: * </td>
  10. <td width="350"><input type="text" size="55" name="email"></td>
  11. </tr>
  12. <tr>
  13. <td width="150"><p class="content">Question: * </td>
  14. </tr>
  15. <tr>
  16. <td width="350" colspan="2"><textarea cols="59" rows="5"></textarea name="question"></td>
  17. </tr>
  18. <tr>
  19. <td colspan="2" align="right"><input type="submit" value="Submit" name="submit"></td>
  20. </tr>
  21. <tr>
  22. <td>&nbsp;</td>
  23. </tr>
  24. </form>
  25. </table>

And here is the .php file:

  1. <?php
  2. if (isset($_POST["submit"]))
  3. {
  4. $name = $_POST['name'];
  5. $email = $_POST['email'];
  6. $question = $_POST['question'];
  7. $message = "Message from $name \n Message: $question";
  8.  
  9. mail($email,Inquiry,$message);
  10. echo "Message sent.";
  11. }
  12. else
  13. {
  14. echo "Sending failed, please input the required fields.";
  15. }
  16. ?>

The problem that i'm encountering here is, in each textbox in the.html file i just live it blank, once that i click on the "Submit" button, the output that would be displayed is "Message sent.", instead of "Sending failed, please input the required fields."

Please help me here.. Thanks, been trying to solve it for almost 6hours already, and still i get the same output.

thanks in advance.
Last edited by JerieLsky; Sep 14th, 2009 at 7:40 am.
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
  #2
Sep 14th, 2009
you should have check first if the fields are not empty?

  1. <?php
  2. // you should check if this fields are empty
  3. if($_POST['name']=="" || $_POST['email']=="" || $_POST['question']=="")
  4. {
  5. echo "Sending failed, please input the required fields.";
  6. }else{
  7. $name = $_POST['name'];
  8. $email = $_POST['email'];
  9. $question = $_POST['question'];
  10. $message = "Message from $name \n Message: $question";
  11. if(mail($email,Inquiry,$message))
  12. echo "Message sent.";
  13. else
  14. echo "Message sending failed";
  15. }

For now, you might already get the idea. Hope it helps
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 43
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
  #3
Sep 14th, 2009
I used the code that you suggested but nothing has been displayed or no output at all. What is the use of the isset() function in the if-else statement then?
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
  #4
Sep 14th, 2009
Originally Posted by JerieLsky View Post
I used the code that you suggested but nothing has been displayed or no output at all. What is the use of the isset() function in the if-else statement then?
you are checking if the post method has been set or is the submit button been submitted.
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 43
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
  #5
Sep 14th, 2009
Ahm, what is then the problem on the code why does it not display anything?
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
  #6
Sep 14th, 2009
the problem is, this part

  1. <td width="350" colspan="2"><textarea cols="59" rows="5"></textarea name="question"></td>

try changing it to this

  1. <td width="350" colspan="2"><textarea cols="59" rows="5" name="question"></textarea></td>

and use the code that i've given earlier
Last edited by ivatanako; Sep 14th, 2009 at 8:58 am.
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 43
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
  #7
Sep 14th, 2009
Seriously, still no output. I even tried adding this statement in the .php file
  1. echo "Me";
it actually showed nothing. I added that statement after the <?php tag and before the if-else statement, here:
  1. <?php
  2. echo "Me";
  3. if($_POST['name']=="" || $_POST['email']=="" || $_POST['question']=="")
  4. {
  5. echo "Sending failed, please input the required fields.";
  6. }
  7. else
  8. {
  9. $name = $_POST['name'];
  10. $email = $_POST['email'];
  11. $question = $_POST['question'];
  12. $message = "Message from $name \n Message: $question";
  13.  
  14. if(mail($email,Inquiry,$message))
  15. echo "Message sent.";
  16. else
  17. echo "Message sending failed";
  18. }
  19. ?>

so confusing..
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
  #8
Sep 14th, 2009
Originally Posted by JerieLsky View Post
Seriously, still no output. I even tried adding this statement in the .php file
  1. echo "Me";
it actually showed nothing. I added that statement after the <?php tag and before the if-else statement, here:
  1. <?php
  2. echo "Me";
  3. if($_POST['name']=="" || $_POST['email']=="" || $_POST['question']=="")
  4. {
  5. echo "Sending failed, please input the required fields.";
  6. }
  7. else
  8. {
  9. $name = $_POST['name'];
  10. $email = $_POST['email'];
  11. $question = $_POST['question'];
  12. $message = "Message from $name \n Message: $question";
  13.  
  14. if(mail($email,Inquiry,$message))
  15. echo "Message sent.";
  16. else
  17. echo "Message sending failed";
  18. }
  19. ?>

so confusing..

do you have a mailserver? i tested your code on my machine.. and im sure that it is working.

try removing the mail function then try outputting just plain text
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
  #9
Sep 14th, 2009
  1. if(mail($email,Inquiry,$message))

try changing the 'inquiry'
Last edited by ivatanako; Sep 14th, 2009 at 9:33 am.
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 43
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
  #10
Sep 14th, 2009
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?
Reply With Quote Quick reply to this message  
Reply

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




Views: 794 | Replies: 21
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2010 DaniWeb® LLC