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 = "[email protected]";

$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
https://forums.phpfreaks.com/topic/211135-php-email-form-button-not-working/
Share on other sites

this HTML is over the top of it, so you can't click on the button (in FF)

<div style="position: absolute; left: 4%; top: 40%; width: 100%; height: 500px;" id="mainbody2" class="bodytext"><br></div>

remove that html and it should be fine

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 =/

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.