Jump to content

PHP email form button not working!


Marvin0410

Recommended Posts

Hello all,

 

I'm sorry for posting twice in one week; I'm teaching myself PHP at the moment...it isn't easy, but it's rewarding :).

 

That being said, I'm trying to make an email form using PHP...I handle page navigations by getting HTML from text files and calling $(div_name).html(text);. Works fine up until I call the HTML for my form; the Email Me button doesn't even click! I'm not sure if this is a PHP problem, but any help would be greatly appreciated!

 

The HTML I call from a text file is as follows:

 

<form name="contactform" method="post" action="form_email.php">

<table width="100%" border="0">

<tr>

<td>Name: </td>

<td> <input type="text" name="_name" maxlength="30" size="30" /> </td>

</tr>

<tr>

<td>Contact Email: </td>

<td> <input type="text" name="email_address" maxlength="30" size="30" /> </td>

</tr>

<tr>

<td> Message: </td>

<td> <input type="text" name="_message" maxlength="500" width="100" height="300" /> </td>

</tr>

<tr>

<td> <input type ="Submit" name="Submit" value="Email Me!" /> </td>

</tr>

</table>

</form>

 

The AJAX I use to insert the above text as HTML in a div is:

 

$.ajax({

url : "introtext.txt",

success : function (data) {

$("#mainbody").html(data);

}

});

 

Finally, the PHP for the form is:

 

<?php

 

//variables

$email_to = "mserrano0410@gmail.com";

$email_subject = "Inquiry from my personal website";

 

$sender_name = $_POST['_name'];

$sender_email = $_POST['email_address'];

$sender_message = $_POST['_message'];

 

//set up the message to send.

$main_message = "You received the following message from your personal website at ".getdate()."\n\n";

$main_message.="Name: ".$sender_name."\n";

$main_message.="Sender's Email: ".$sender_email."\n";

$main_message.="Message: ".$sender_message."\n";

 

//send the email to myself.

@mail($email_to, $email_subject, $main_message);

 

?>

 

 

Oh, and the site is www.personal.psu.edu/mrs5171/index.php.

 

Any help would be awesome!

 

-Marvin

 

 

Link to comment
Share on other sites

Sorry, I just tried it again...that div tag is actually separate from the form...the form is (supposed) to be inserted into the div labeled "mainbody" as html using Javascript...basically, it's supposed to be one div and the form inside of it.

 

I'm thinking it's a problem with my form itself, or the PHP...but I'm really not sure =/

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.