Batista
Executive Member
- Joined
- Sep 2, 2011
- Messages
- 7,906
- Reaction score
- 266
I cant spend too much time on this anymore :
I have a single htm page and a single email.php.Its a contact form.The email.php works if i hardcode values in and then visit the page, the html refuses to invoke the email.php hence nothing happens.
My html page (stripped down to show simplicity)
My email.php (which works if I hardcode values in and run on website)
Pls help, it seems that my html isnt talking to my php. :'(
I have a single htm page and a single email.php.Its a contact form.The email.php works if i hardcode values in and then visit the page, the html refuses to invoke the email.php hence nothing happens.
My html page (stripped down to show simplicity)
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-3">
<form role = "form" method="post" action="email.php" name= "mymailform">
<div class="form-group">
<input name="fullname" type="fullname" class="form-control" id="fullname" placeholder="Your Name" maxlength="30">
</div>
<div class="form-group">
<input name="email" type="email" class="form-control" id="email" placeholder="Your Email" maxlength="30">
</div>
<div class="form-group">
<input name="subject" type="text" class="form-control" id="subject" placeholder="Your Subject" maxlength="40">
</div>
<div><button name="btnsubmit" type="button" input type="submit" class="btn btn-primary" id = "btnsubmit">Send Message</button></div>
</form>
</div>
<div class="col-md-9">
<div class="txtarea">
<textarea name="message" rows="10" class="form-control" id="message"></textarea>
</div>
</div>
</div>
</div>
</body>
</html>
My email.php (which works if I hardcode values in and run on website)
Code:
<?php
require("PHPMailer_5.2.0/class.phpmailer.php");
$email = $_POST['email'] ;
$message = $_POST['message'] ;
$name = $_POST['fullname'];
$subject = $_POST['subject'];
echo '<script type="text/javascript">alert("In email.php");</script>';
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "154."; // specify main and backup server
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "[email protected]"; // SMTP username
$mail->Password = "pass"; // SMTP password
$mail->From = $email;
$mail->AddAddress("[email protected]");
// set word wrap to 50 characters
$mail->WordWrap = 50;
// set email format to HTML
$mail->IsHTML(true);
$mail->Subject = $subject;
// $message is the user's message they typed in
// on our contact us page. We set this variable at
// the top of this page with:
// $message = $_REQUEST['message'] ;
$mail->Body = $message;
$mail->AltBody = $message;
echo '<script type="text/javascript">alert("trying to send");</script>';
if(!$mail->Send())
{
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
echo "Message has been sent";
?>
Pls help, it seems that my html isnt talking to my php. :'(