943,901 Members | Top Members by Rank

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

Please Read! php problem.

Expand Post »
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:
PHP Syntax (Toggle Plain Text)
  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:

PHP Syntax (Toggle Plain Text)
  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 8:40 am.
Similar Threads
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.

you should have check first if the fields are not empty?

PHP Syntax (Toggle Plain Text)
  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
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.

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?
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.

Click to Expand / Collapse  Quote originally posted by JerieLsky ...
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.
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.

Ahm, what is then the problem on the code why does it not display anything?
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.

the problem is, this part

PHP Syntax (Toggle Plain Text)
  1. <td width="350" colspan="2"><textarea cols="59" rows="5"></textarea name="question"></td>

try changing it to this

PHP Syntax (Toggle Plain Text)
  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 9:58 am.
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.

Seriously, still no output. I even tried adding this statement in the .php file
PHP Syntax (Toggle Plain Text)
  1. echo "Me";
it actually showed nothing. I added that statement after the <?php tag and before the if-else statement, here:
PHP Syntax (Toggle Plain Text)
  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..
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.

Click to Expand / Collapse  Quote originally posted by JerieLsky ...
Seriously, still no output. I even tried adding this statement in the .php file
PHP Syntax (Toggle Plain Text)
  1. echo "Me";
it actually showed nothing. I added that statement after the <?php tag and before the if-else statement, here:
PHP Syntax (Toggle Plain Text)
  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
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.

PHP Syntax (Toggle Plain Text)
  1. if(mail($email,Inquiry,$message))

try changing the 'inquiry'
Last edited by ivatanako; Sep 14th, 2009 at 10:33 am.
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 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?
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