Page 1 of 1

Form Problem ( new to PHP )

Posted: Wed Aug 11, 2010 11:32 pm
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

Re: Form Problem ( new to PHP )

Posted: Thu Aug 12, 2010 1:04 am
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?

Re: Form Problem ( new to PHP )

Posted: Thu Aug 12, 2010 1:32 am
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.

Re: Form Problem ( new to PHP )

Posted: Thu Aug 12, 2010 8:55 pm
by iskawt
bump... need help..

Re: Form Problem ( new to PHP )

Posted: Mon Aug 16, 2010 11:49 am
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)?

Re: Form Problem ( new to PHP )

Posted: Mon Aug 16, 2010 2:51 pm
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 :(

Re: Form Problem ( new to PHP )

Posted: Mon Aug 16, 2010 3:00 pm
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

Re: Form Problem ( new to PHP )

Posted: Mon Aug 16, 2010 9:45 pm
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?

Re: Form Problem ( new to PHP )

Posted: Tue Aug 17, 2010 12:47 pm
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?

Re: Form Problem ( new to PHP )

Posted: Wed Aug 18, 2010 12:05 am
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.

Re: Form Problem ( new to PHP )

Posted: Wed Aug 18, 2010 1:36 am
by greyhoundcode
OK so can you post your form code? What is the form element's action attribute set to?

Re: Form Problem ( new to PHP )

Posted: Wed Aug 18, 2010 7:26 am
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.

Re: Form Problem ( new to PHP )

Posted: Wed Aug 18, 2010 8:23 pm
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.

Re: Form Problem ( new to PHP )

Posted: Thu Aug 19, 2010 11:26 am
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?

Re: Form Problem ( new to PHP )

Posted: Thu Aug 19, 2010 9:18 pm
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.