Form Problem ( new to PHP )

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
iskawt
Forum Newbie
Posts: 12
Joined: Wed Aug 11, 2010 11:20 pm

Form Problem ( new to PHP )

Post by iskawt »

Good day guys.

I am really new to PHP and I am currently experimenting on how to create a Form on DreamWeaver.I watched several tutorials to gather information on how to create an effective Form with a script on PHP.

I have a Form that will ask user to input their first name, last name, email, phone number but I can't seem to figure out what's wrong. Here's the code.


Code: Select all

<?php
/* newbie me */

/* Subject and Email */

	$emailSubject = 'sample';
	$emailBoss = 'sampleemail@gmail.com';
	

/*Gathering Data Variables */

	$fnameField = $_POST['firstname'];
	$lnameField = $_POST['lastname'];
	$emailField = $_POST['emailaddress'];
	$rnameField = $_POST['namerecipient'];
	$phoneField = $_POST['phone'];

	
$body = <<<EOD
<br><hr><br>
First Name: $fnameField <br>
Last Name: $lnameField <br>
Email Address: $emailField <br>
Name of Recipient: $rnameField <br>
Phone: $phoneField


EOD;

	$headers = "From: $emailaddress\r\n";
	$headers .= "Content-type: text/html\r\n";
	$success = mail($emailBoss, $emailSubject, $body, $headers);
	
?>
When i clicked "submit" button and checked my mail, nothing mail had been delivered.

I'm really new to PHP programming so I am having hard time to figure out what's wrong with the code. :(

Suggestions are very much appreciated.


Thanks,
iskawt
User avatar
greyhoundcode
Forum Regular
Posts: 613
Joined: Mon Feb 11, 2008 4:22 am

Re: Form Problem ( new to PHP )

Post by greyhoundcode »

Do you have error reporting turned on, and to what level, and are you sure the emails haven't been filtered out as possible junkmail?
iskawt
Forum Newbie
Posts: 12
Joined: Wed Aug 11, 2010 11:20 pm

Re: Form Problem ( new to PHP )

Post by iskawt »

I already uploaded those 2 files on our server sir grey, if click "submit" button, the contactprocess.php file will load but it's just a plain page. ( btw, I also rendered an HTML codes on the bottom part but I want to give emphasize on the email issue).

I also checked junkmail sir, but none of those trials I made were sent.
iskawt
Forum Newbie
Posts: 12
Joined: Wed Aug 11, 2010 11:20 pm

Re: Form Problem ( new to PHP )

Post by iskawt »

bump... need help..
User avatar
greyhoundcode
Forum Regular
Posts: 613
Joined: Mon Feb 11, 2008 4:22 am

Re: Form Problem ( new to PHP )

Post by greyhoundcode »

Insert this above the $body declaration:

Code: Select all

echo '<p>Test<br/>';
print_r($_POST);
echo '</p>';
You should now be able to tell if the code you posted is being executed. What do you see (if anything)?
liamallan
Forum Newbie
Posts: 19
Joined: Sat Aug 14, 2010 6:25 pm

Re: Form Problem ( new to PHP )

Post by liamallan »

i think ur hosts server needs to have sendmail activated.

in other words, ur server may not be set up to send e-mail :(
liamallan
Forum Newbie
Posts: 19
Joined: Sat Aug 14, 2010 6:25 pm

Re: Form Problem ( new to PHP )

Post by liamallan »

copy and paste this into a new php file:

Code: Select all

<?php phpinfo(); ?>
call it phpinfo.php or something, upload it then access it on ur browser.

look for the table with the heading 'PHP CORE' then look down that table till u find 'sendmail', and u should be able to tell if ur host supports sendmail
iskawt
Forum Newbie
Posts: 12
Joined: Wed Aug 11, 2010 11:20 pm

Re: Form Problem ( new to PHP )

Post by iskawt »

@sir greyhoundcode

I don't see anything sir, after I clicked the submit button and still didn't receive a mail from the form.

@ sir liamallan

there's no value for the sendmail_from but there's a value for sendmail_path, what does that mean.

Also, i noticed one of our site who has a form, used PHPMailer. Does it mean our server doesn't support send mail?
User avatar
greyhoundcode
Forum Regular
Posts: 613
Joined: Mon Feb 11, 2008 4:22 am

Re: Form Problem ( new to PHP )

Post by greyhoundcode »

iskawt wrote:I don't see anything sir, after I clicked the submit button and still didn't receive a mail from the form.
Are you sure that the form data is being posted to the correct URL?
iskawt
Forum Newbie
Posts: 12
Joined: Wed Aug 11, 2010 11:20 pm

Re: Form Problem ( new to PHP )

Post by iskawt »

yes sir grey. The code above on my first post is in contactprocess.php with an HTML code that will simple display "Thank you for your Interest!"

But even the HTML page, doesn't appear. If I click "submit" button, it will go to contactprocess.php page without any display.
User avatar
greyhoundcode
Forum Regular
Posts: 613
Joined: Mon Feb 11, 2008 4:22 am

Re: Form Problem ( new to PHP )

Post by greyhoundcode »

OK so can you post your form code? What is the form element's action attribute set to?
pollock
Forum Newbie
Posts: 9
Joined: Tue Jun 29, 2010 7:23 am

Re: Form Problem ( new to PHP )

Post by pollock »

You will go through this link http://dreamweaverspot.com/adobe-dreamw ... act-forms/. Here some tutorials about dream weaver.I dam sure that you will satisfied if you will read this.
iskawt
Forum Newbie
Posts: 12
Joined: Wed Aug 11, 2010 11:20 pm

Re: Form Problem ( new to PHP )

Post by iskawt »

Code: Select all

<form action="contactprocess.php" method="post" name="form1">
          <p>&nbsp;</p>
        <center><table width="502" border="0" cellspacing="0" cellpadding="3">
            <tr>
              <td width="173"><div align="right">
                <label for="firstname"><span class="style1">First Name:</span></label>
              </div></td>
              <td width="317"><div align="left">
                <input name="firstname" type="text" id="firstname" size="35" maxlength="50">
              </div></td>
            </tr>
            <tr>
              <td><div align="right" class="style1">
                <label for="lastname">Last Name:</label>
              </div></td>
              <td><div align="left"><span class="style1">
                <input name="lastname" type="text" id="lastname" size="35" maxlength="50">
              </span></div></td>
            </tr>
            <tr>
              <td><div align="right">
                <label for="emailaddress"><span class="style1">E-mail Address:</span></label>
              </div></td>
              <td><div align="left">
                <input name="emailaddress" type="text" id="emailaddress" size="35" maxlength="90">
              </div></td>
            </tr>
            <tr>
              <td><div align="right">
                <label for="paypalaccount"><span class="style1">PayPal Account Address:</span></label>
              </div></td>
              <td><div align="left">
                <input name="paypalaccount" type="text" id="paypalaccount" size="35" maxlength="90">
              </div></td>
            </tr>
            <tr>
              <td><div align="right" class="style1">Recipient's Information</div></td>
              <td><div align="left"></div></td>
            </tr>
            <tr>
              <td><div align="right">
                <label for="namerecipient"><span class="style1">Name of Recipient:</span></label>
              </div></td>
              <td><div align="left">
                <input name="namerecipient" type="text" id="namerecipient" size="35" maxlength="50">
              </div></td>
            </tr>
            <tr>
              <td><div align="right">
                <label for="phone"><span class="style1">Phone:</span></label>
              </div></td>
              <td><div align="left">
                <input name="phone" type="text" id="phone" size="35" maxlength="20">
              </div></td>
            </tr>
            <tr>
              <td><div align="right">
                <label for="recipientemail"><span class="style1">E-mail:</span></label>
              </div></td>
              <td><div align="left">
                <input name="recipientemail" type="text" id="recipientemail" size="35" maxlength="50">
              </div></td>
            </tr>
            <tr>
              <td><div align="right">
                <label for="amount"><span class="style1">Amount To Send:</span></label>
              </div></td>
              <td><div align="left">
                <input name="amount" type="text" id="amount" size="35" maxlength="50">
              </div></td>
            </tr>
            <tr>
              <td><div align="right">
                <label for="clear"></label>
                <input type="reset" name="clear" id="clear" value="Reset">
              </div></td>
              <td><div align="left">
                <label for="submit"></label>
                <input type="submit" name="submit" id="submit" value="Submit">
              </div></td>
            </tr>
          </table></center>
          </form>
That's my form code sir grey.
User avatar
greyhoundcode
Forum Regular
Posts: 613
Joined: Mon Feb 11, 2008 4:22 am

Re: Form Problem ( new to PHP )

Post by greyhoundcode »

If you call contactprocess.php directly, ie without using the contact form, what do you see? If you insert an echo statement at the top of contactprocess.php, ie,

Code: Select all

echo 'Test';
Do you see this text?
iskawt
Forum Newbie
Posts: 12
Joined: Wed Aug 11, 2010 11:20 pm

Re: Form Problem ( new to PHP )

Post by iskawt »

hmmm, it doesn't display the string sir. It will display if i omit the HTML code that should be render after they clicked the "submit" button sir.
Post Reply