I have a webpage coded in HTML that I have added a form to. What I would like is for our employees to go to the URL of the webpage, fill out the form with the customer's name, address, email and appointment date and time, then for a complete copy of the webpage and form data to be sent to the email specified in the form. Essentially, our employees will be using the webpage/form to send appointment confirmations to our clients using email. Our clients will receive the coded HTML with form data in their email, confirming their appointment times. Would like to use PHP for the server-side processing of all this.
Thanks for all your help
<html>
<head>
<title>emailConfirm-Appointment</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<!-- Save for Web Slices (emailConfirm-Appointment.psd) -->
<table id="Table_01" width="612" height="792" border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan="5" bgcolor="#FFFFFF">
<img src="http://www.cfproroofing.com/email/images/emailConfirmAppt-header.jpg" alt="" width="612" height="165" border="0"></td>
</tr>
<tr>
<td colspan="5" bgcolor="#FFFFFF">
<img src="http://www.cfproroofing.com/email/images/emailConfirmAppt-title.png" alt="" width="612" height="31" border="0"></td>
</tr>
<tr>
<td height="130" colspan="3" valign="top">
<fieldset align="right">
<!-- a helper script for vaidating the form-->
<script language="JavaScript" src="scripts/gen_validatorv31.js" type="text/javascript"></script>
<form method="POST" name="contactform" action="testForm-handler.php">
<label for='name'><span style="font-size:14px">Customer:</span></label>
<input type="text" name="name"> <br>
<label for='email'><span style="font-size:14px">Email:</span></label>
<input type="text" name="email"> <br>
<label for='address'><span style="font-size:14px">Address:</span></label>
<input type="text" name="address"> <br>
<label for='city'><span style="font-size:14px">City:</span></label>
<input type="text" name="city"> <br>
<label for='date-time'><span style="font-size:14px">Date & Time:</span></label>
<input type="text" name="date-time"> <br>
<input type="submit" value="Submit"><br>
</form>
</fieldset>
<script language="JavaScript">
// Code for validating the form
// Visit http://www.javascript-coder.com/html-form/javascript-form-validation.phtml
// for details
var frmvalidator = new Validator("contactform");
frmvalidator.addValidation("name","req","Please provide your name");
frmvalidator.addValidation("email","req","Please provide your email");
frmvalidator.addValidation("email","email","Please enter a valid email address");
</script></td>
</tr>
<tr>
<td colspan="5" bgcolor="#FFFFFF">
<img src="http://www.cfproroofing.com/email/images/emailConfirmAppt-body_Walter.jpg" alt="" width="612" height="237" border="0"></td>
</tr>
<tr>
<td width="102.5" height="44" bgcolor="#FFFFFF">
<img src="images/spacer.gif" width="102.5" height="44" alt=""></td>
<td width="102.5" height="44" bgcolor="#FFFFFF">
<img src="images/spacer.gif" width="102.5" height="44" alt=""></td>
<td width="203" bgcolor="#FFFFFF">
<a href="http://www.CFProRoofing.com" target="_blank">
<img src="http://www.cfproroofing.com/email/images/emailConfirmAppt-buttonWebsite.png" width="203" height="44" border="0" alt=""></a></td>
<td width="102.5" height="44" bgcolor="#FFFFFF">
<img src="images/spacer.gif" width="102.5" height="44" alt=""></td>
<td width="102.5" height="44" bgcolor="#FFFFFF">
<img src="images/spacer.gif" width="102.5" height="44" alt=""></td>
</tr>
<tr>
<td colspan="5" bgcolor="#FFFFFF">
<img src="http://www.cfproroofing.com/email/images/emailConfirmAppt-signatureKalina.jpg" alt="" width="612" height="122" border="0"></td>
</tr>
<tr>
<td colspan="5" bgcolor="#FFFFFF">
<img src="http://www.cfproroofing.com/email/images/emailConfirmAppt-footer.png" alt="" width="612" height="83" border="0"></td>
</tr>
</table>
<!-- End Save for Web Slices -->
</body>
</html>
<?php
$errors = '';
$sendTo = "test#plantosellfl.com";//<-----Put Your email address here.
if(empty($_POST['name']) ||
empty($_POST['email']) ||
empty($_POST['address']) ||
empty($_POST['city']) ||
empty($_POST['date-time']))
{
$errors .= "\n Error: all fields are required";
}
$name = $_POST['name'];
$email_address = $_POST['email'];
$address = $_POST['address'];
$city = $_POST['city'];
$date_time = $_POST['date-time'];
if (!preg_match(
"/^[_a-z0-9-]+(\.[_a-z0-9-]+)*#[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i",
$email_address))
{
$errors .= "\n Error: Invalid email address";
}
if( empty($errors))
{
$to = $sendTo;
$email_subject = "Confirm Appointment: $address";
$email_body ='<html>
<head>
<title>emailConfirm-Appointment</title>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="612px" height="792px" border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan="5" bgcolor="#FFFFFF">
<img src="http://www.cfproroofing.com/email/images/emailConfirmAppt-header.jpg" alt="" width="612" height="165" border="0">
</td>
</tr>
<tr>
<td colspan="5" bgcolor="#FFFFFF">
<img src="http://www.cfproroofing.com/email/images/emailConfirmAppt-title.png" alt="" width="612" height="31" border="0">
</td>
</tr>
<tr>
<td height="130" colspan="3" valign="top" border="0">
<?php echo $_POST["name"]; ?><br>
<?php echo $_POST["email"]; ?><br>
<?php echo $_POST["address"]; ?><br>
<?php echo $_POST["city"]; ?><br>
<?php echo $_POST["date-time"]; ?><br>
</td>
</tr>
<tr>
<td colspan="5" bgcolor="#FFFFFF">
<img src="http://www.cfproroofing.com/email/images/emailConfirmAppt-body_Walter.jpg" alt="" width="612" height="237" border="0">
</td>
</tr>
<tr>
<td width="102.5" height="44" bgcolor="#FFFFFF">
<img src="http://www.cfproroofing.com/email/images/spacer.gif" width="102.5" height="44" alt="">
</td>
<td width="102.5" height="44" bgcolor="#FFFFFF">
<img src="http://www.cfproroofing.com/email/images/spacer.gif" width="102.5" height="44" alt="">
</td>
<td width="203" bgcolor="#FFFFFF">
<a href="http://www.CFProRoofing.com" target="_blank">
<img src="http://www.cfproroofing.com/email/images/emailConfirmAppt-buttonWebsite.png" width="203" height="44" border="0" alt=""></a>
</td>
<td width="102.5" height="44" bgcolor="#FFFFFF">
<img src="http://www.cfproroofing.com/email/images/spacer.gif" width="102.5" height="44" alt="">
</td>
<td width="102.5" height="44" bgcolor="#FFFFFF">
<img src="http://www.cfproroofing.com/email/images/spacer.gif" width="102.5" height="44" alt="">
</td>
</tr>
<tr>
<td colspan="5" bgcolor="#FFFFFF">
<img src="http://www.cfproroofing.com/email/images/emailConfirmAppt-signatureKalina.jpg" alt="" width="612" height="122" border="0">
</td>
</tr>
<tr>
<td colspan="5" bgcolor="#FFFFFF">
<img src="http://www.cfproroofing.com/email/images/emailConfirmAppt-footer.png" alt="" width="612" height="83" border="0">
</td>
</tr>
</table>
<!-- End Save for Web Slices -->
</body>
</html>
';
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n";
$headers .= 'From: <KaMendez#CFProRoofing.com>' . "\r\n";
$headers .= 'Reply-To: <KaMendez#CFProRoofing.com>' . "\r\n";
mail($to,$email_subject,$email_body,$headers);
}
?>
In your code, when you build the $email_body, you want to insert the $_POST variables inside it.
You don't need to put the <?php $_POST["name"] ?> tag inside it: it won't be interpreted as it is just part of the string. In fact php just suppose that you want to send a string with a less-than sign, then a question mark and so on.
If you want to put a viariable in your string try:
$email_body ='<html>
...
... html stuff ...
...
<td height="130" colspan="3" valign="top" border="0">
';
$email_body .= $_POST["name"];
$email_body .= $_POST["email"];
$email_body .= $_POST["address"];
$email_body .='</td>
...
... html stuff again ...
...
</html>';
In this way:
First you set a string with some HTML code in $email_body. And this HTML string is inside single apex-s!
Then you concatenate to it your variables (these are not inside apexs)
Then you concatenate a string of HTML again.
Related
I'm pretty new to WordPress and web development. I've been working on converting an older website to WordPress for a person I do business with. I've got almost everything done, but I'm having trouble getting his contact form to work properly. I've created a custom template for the page, but am not sure how to get the page for when the email is sent to work. My template code looks like this
<?php
/*Template Name: Contact*/
?>
<?php
get_header();
?>
<?php $nav = get_field ('navigation_links'); ?>
<body bgcolor="#ffffff" onload="MM_preloadImages('<?php bloginfo('template_directory')?>/menu_images/masthead_r2_c1_s2.png','<?php bloginfo('template_directory')?>/menu_images/masthead_r2_c1_s4.png','<?php bloginfo('template_directory')?>/menu_images/masthead_r2_c1_s3.png','<?php bloginfo('template_directory')?>/menu_images/masthead_r2_c3_s2.png','<?php bloginfo('template_directory')?>/menu_images/masthead_r2_c3_s4.png','<?php bloginfo('template_directory')?>/menu_images/masthead_r2_c3_s3.png','<?php bloginfo('template_directory')?>/menu_images/masthead_r2_c5_s2.png','<?php bloginfo('template_directory')?>/menu_images/masthead_r2_c5_s4.png','<?php bloginfo('template_directory')?>/menu_images/masthead_r2_c5_s3.png','<?php bloginfo('template_directory')?>/menu_images/masthead_r2_c7_s2.png','<?php bloginfo('template_directory')?>/menu_images/masthead_r2_c7_s4.png','<?php bloginfo('template_directory')?>/menu_images/masthead_r2_c7_s3.png');">
<div class = "container" style = "background-image:url(<?php bloginfo('template_directory')?>/images/Generic_Background.jpg);">
<div id="header" style="position:relative;">
<div id="FWTableContainer1270816879">
<table style="display: inline-table;" border="0" cellpadding="0" cellspacing="0" width="960">
<!-- fwtable fwsrc="masthead.png" fwpage="Page 1" fwbase="masthead.png" fwstyle="Dreamweaver" fwdocid = "1270816879" fwnested="0" -->
<tr>
<td><img src="<?php bloginfo('template_directory')?>/menu_images/spacer.gif" width="179" height="1" border="0" alt="" /></td>
<td><img src="<?php bloginfo('template_directory')?>/menu_images/spacer.gif" width="55" height="1" border="0" alt="" /></td>
<td><img src="<?php bloginfo('template_directory')?>/menu_images/spacer.gif" width="179" height="1" border="0" alt="" /></td>
<td><img src="<?php bloginfo('template_directory')?>/menu_images/spacer.gif" width="89" height="1" border="0" alt="" /></td>
<td><img src="<?php bloginfo('template_directory')?>/menu_images/spacer.gif" width="179" height="1" border="0" alt="" /></td>
<td><img src="<?php bloginfo('template_directory')?>/menu_images/spacer.gif" width="68" height="1" border="0" alt="" /></td>
<td><img src="<?php bloginfo('template_directory')?>/menu_images/spacer.gif" width="199" height="1" border="0" alt="" /></td>
<td><img src="<?php bloginfo('template_directory')?>/menu_images/spacer.gif" width="12" height="1" border="0" alt="" /></td>
<td><img src="<?php bloginfo('template_directory')?>/menu_images/spacer.gif" width="1" height="1" border="0" alt="" /></td>
</tr>
<tr>
<td colspan="8"><img name="masthead_r1_c1_s1" src="<?php bloginfo('template_directory')?>/menu_images/masthead_r1_c1_s1.png" width="960" height="193" border="0" id="masthead_r1_c1_s1" alt="" /></td>
<td><img src="<?php bloginfo('template_directory')?>/menu_images/spacer.gif" width="1" height="193" border="0" alt="" /></td>
</tr>
<tr>
<td><img name="masthead_r2_c1_s1" src="<?php bloginfo('template_directory')?>/menu_images/masthead_r2_c1_s1.png" width="179" height="43" border="0" id="masthead_r2_c1_s1" alt="" /></td>
<td><img name="masthead_r2_c2_s1" src="<?php bloginfo('template_directory')?>/menu_images/masthead_r2_c2_s1.png" width="55" height="43" border="0" id="masthead_r2_c2_s1" alt="" /></td>
<td><img name="masthead_r2_c3_s1" src="<?php bloginfo('template_directory')?>/menu_images/masthead_r2_c3_s1.png" width="179" height="43" border="0" id="masthead_r2_c3_s1" alt="" /></td>
<td><img name="masthead_r2_c4_s1" src="<?php bloginfo('template_directory')?>/menu_images/masthead_r2_c4_s1.png" width="89" height="43" border="0" id="masthead_r2_c4_s1" alt="" /></td>
<td><img name="masthead_r2_c5_s1" src="<?php bloginfo('template_directory')?>/menu_images/masthead_r2_c5_s1.png" width="179" height="43" border="0" id="masthead_r2_c5_s1" alt="" /></td>
<td><img name="masthead_r2_c6_s1" src="<?php bloginfo('template_directory')?>/menu_images/masthead_r2_c6_s1.png" width="68" height="43" border="0" id="masthead_r2_c6_s1" alt="" /></td>
<td><img name="masthead_r2_c7_s1" src="<?php bloginfo('template_directory')?>/menu_images/masthead_r2_c7_s1.png" width="199" height="43" border="0" id="masthead_r2_c7_s1" alt="" /></td>
<td><img name="masthead_r2_c8_s1" src="<?php bloginfo('template_directory')?>/menu_images/masthead_r2_c8_s1.png" width="12" height="43" border="0" id="masthead_r2_c8_s1" alt="" /></td>
<td><img src="<?php bloginfo('template_directory')?>/menu_images/spacer.gif" width="1" height="43" border="0" alt="" /></td>
</tr>
</table>
<div id="MMMenuContainer1120175513_0">
<div id="MMMenu1120175513_0" onmouseout="MM_menuStartTimeout(1000);" onmouseover="MM_menuResetTimeout();"> Pistols & Knives Rifles & Shotguns Collectibles & Antiques </div>
</div>
</div>
</div>
<div class="content" style="position:relative;">
<!-- InstanceBeginEditable name="maincontent" --><div id="centertable"><center><table width="70%" border="0" cellpadding="2" cellspacing="0" style="background-color:#fcb076;">
<tr>
<td align="center"><h2 style="margin-top:4px;">Contact Information</h2> <h5>Phone: 574.295.6440<br />
Monday – Friday 9:00 am – 5:00 pm Eastern Standard Time</h5>
<h5>Saturdays 9:00 am - noon<br />
Fax: 574.522.1600 (Anytime)</h5></td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center"><h5>Mailing Address:<br />
22382 State Road 120 Elkhart, IN 46516</h5></td>
<td align="center"><h5>Physical Address:<br />
22382 State Road 120 Elkhart, IN 46516</h5></td>
</tr>
</table></td>
</tr>
<tr>
<td align="center"><h5>E-mail - paul.stybert#gmail.com</h5></td>
</tr>
<tr>
<td><h5>If you have questions, you can reach us by phone, fax, regular mail, or use the email form below. This form will be sent to a customer service representative, who will be in contact with you soon. Thank you for your interest in Doug's Guns.</h5></td>
</tr>
<tr style="background-color:#005d90;color:#fff;">
<td align="center" style="border:1px solid #000;"><h3>Online Information Request Form</h3></td>
</tr>
<tr >
<td align="center" style="border:1px solid #000;background-color:#d3a06f;"><form action="<?php bloginfo('template_directory')?>/template-emailproc.php" method="post" id="mailform" name="mailform">
<input type="hidden" value="yxstreme" name="name" />
<table width="80%" border="0" cellspacing="0" cellpadding="2" class="formtable" style="margin-top:0px;">
<tr>
<td align="right" valign="top">*Name</td>
<td align="left" valign="top"><span id="sprytextfield1">
<input type="text" name="txtName" id="txtName" />
<span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldMinCharsMsg">Minimum number of characters not met.</span><span class="textfieldMaxCharsMsg">Exceeded maximum number of characters.</span></span></td>
</tr>
<tr>
<td align="right" valign="top">*Email</td>
<td align="left" valign="top"><span id="sprytextfield2">
<input type="text" name="txtEmail" id="txtEmail" />
<span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></td>
</tr>
<tr>
<td align="right" valign="top">Company</td>
<td align="left" valign="top"><label for="txtCompany"></label>
<input type="text" name="txtCompany" id="txtCompany" /></td>
</tr>
<tr>
<td align="right" valign="top">Address</td>
<td align="left" valign="top"><label for="txtAddress"></label>
<input type="text" name="txtAddress" id="txtAddress" /></td>
</tr>
<tr>
<td align="right" valign="top">City</td>
<td align="left" valign="top"><label for="txtCity"></label>
<input type="text" name="txtCity" id="txtCity" /></td>
</tr>
<tr>
<td align="right" valign="top">State</td>
<td align="left" valign="top"><label for="txtState"></label>
<input type="text" name="txtState" id="txtState" /></td>
</tr>
<tr>
<td align="right" valign="top">Postal Code</td>
<td align="left" valign="top"><label for="txtPostalCode"></label>
<input type="text" name="txtPostalCode" id="txtPostalCode" /></td>
</tr>
<tr>
<td align="right" valign="top">Phone</td>
<td align="left" valign="top"><label for="txtPhone"></label>
<input type="text" name="txtPhone" id="txtPhone" /></td>
</tr>
<tr>
<td align="right" valign="top">Interested In:</td>
<td align="left" valign="top"><select name="ddInterest" class="contactformoption" id="ddInterest">
<option value="null" selected="selected">Please Choose One</option>
<option value="Buying One Of Our Products">Buying One Of Our Products</option>
<option value="Pistols">Pistols</option>
<option value="Rifles or Shotguns">Rifles or Shotguns</option>
<option value="Collectibles">Collectibles</option>
<option value="Other">Other</option></select></td>
</tr>
<tr>
<td align="right" valign="top">How did you find our website?</td>
<td align="left" valign="top">
<input type="text" name="txtHowFind" id="txtHowFind" /></td>
</tr>
<tr>
<td align="right" valign="top">Comments/Questions</td>
<td align="left" valign="top"><label for="txtComment"></label>
<textarea name="txtComments" id="txtComment" cols="60" rows="5"></textarea></td>
</tr>
<tr>
<td align="right" valign="top"> </td>
<td align="left" valign="top"><input type="submit" name="btnSubmit" id="btnSubmit" value="Send" /></td>
</tr>
</table>
</form>
</td>
</tr>
</table></center>
</div>
<!-- InstanceEndEditable -->
<!-- end .content --></div>
<!-- end .container --></div>
</body>
<?php wp_footer();?>
<!-- InstanceEnd --></html>
I know it has something to do with the post method and where the email is being sent I changed the link to a page I've created with a custom template. The code that is different in that template is
<div class="content" id="maincontent"><!-- InstanceBeginEditable name="MainContent" -->
<%
on error resume next
xname=request.form("txtName")
xemail=request.form("txtEmail")
xcompany=request.form("txtCompany")
xaddress=request.form("txtAddress")
xcity=request.form("txtCity")
xstate=request.form("txtState")
xpostalcode=request.form("txtPostalCode")
xphone=request.form("txtPhone")
xinterest=request.form("ddInterest")
xhowfind=request.form("txtHowFind")
xcomments=request.form("txtComments")
If Request.form("name") = "yxstreme" Then
psFrom="no-reply#plugguardstore.com"
psSubject="Contact from Doug's Guns Website"
' message body
psbody = "<html><head><title>E-mail sent from the Doug's Guns website</title></head>"
psBody="<body><h5>The following e-mail was sent from the Doug's Guns website :</h5>"
psBody=psBody & "<hr />"
psBody=psBody & "<p>Name: " & xname & "</p>"
psBody=psBody & "<p>Email" & xemail & "<br />Company: " & xcompany & "<br />Address: " & xaddress & "<br />"
psBody=psBody & "City: " & xcity & "<br />State: " & xstate & "<br />Postal Code: " & xpostalcode & "<br />"
psBody=psBody & "Phone: " & xphone & "<br />"
psBody=psBody & "Interested In: " & xinterest & "<br /><br />"
psBody=psBody & "Discovered Website How: " & xhowfind & "<br /><br />"
psBody=psBody & "Comment/question:<br />" & xcomments & "<br /><br />"
psBody=psBody & "</body></html>"
strErr = ""
bSuccess = False
'On Error Resume Next
'sendCDOHTMLEmail "paul.stybert#gmail.com",psFrom,psSubject,psBody
sendCDOHTMLEmail "paul.stybert#gmail.com.com",psFrom,psSubject,psBody
'sendCDONTSHTMLEmail "paul.stybert#gmail.com",psFrom,psSubject,psBody,1
If Err <> 0 Then ' error occurred
strErr = Err.Description
response.write "<center><h3>There was a problem sending your message.</h3></center>"
'response.write Err.Description
else
bSuccess = True
response.write "<center><h3>Thanks! Someone will be in touch with you shortly.</h3></center>"
End If
End If
%>
<!-- InstanceEndEditable --><!-- end .content --></div>
I'm lost on what I need to do to make this work. Any help would be appreciated. For your information the website was originally created with DreamWeaver and I've been moving the html code over and adding php for WordPress into it.
As I understand you want to ditch the asp processing for a Wordpress solution?
Apart from the good suggestion that #biesior gave about a form plugin (ninja forms, gravity forms), this would in your case be done by leaving the action part of the form empty (the form will then post to the same page) and handling the post variables and mailing in your template, just above the get_header(). You would also need to put conditions around the form content like this: if (!isset($_POST["btnSubmit"]) { ... }, so that it doesn't show if the form has been posted.
Look into the wp_mail function. And put a nonce in that form and probably a (re)captcha.
But, forms are nasty and a lot of work, so look into one of the popular form plugins. You'll set this one up in no-time
i am currently having problem sending mail to more than one users in php, i am able to send to one user at a time but the mail function only sends the mail to the first user and does not send the mail to the second one seperated by comma in $to variable.
Here is my code:
<?php
$reg = #$_POST['reg'];
if($reg) {
$to = "mail1#mail.com,mail2#mail.com";
$from = "hootpile#hootpile.com";
$subject = 'Hi VITian !';
$message = '<!DOCTYPE html><html><head><meta charset="UTF-8"><title>Hi VITian.</title></head><body style="margin:0px; font-family:Tahoma, Geneva, sans-serif;"><center>
<table id="ecxbodyTable" width="100%" height="100%" cellspacing="0" cellpadding="0" border="0" align="center" style="border-collapse:collapse;padding:0;background-color:#F2F2F2;height:100% !important;width:100% !important;">
<tbody>
<tr>
<td id="ecxbodyCell" valign="top" align="center" style="padding:20px;border-top:0;height:100% !important;width:100% !important;">
<table id="ecxtemplateContainer" width="600" cellspacing="0" cellpadding="0" border="0" style="border-collapse:collapse;border:0;">
<tbody>
<tr>
<td valign="top" align="center" style="">
<table id="ecxtemplatePreheader" width="600" cellspacing="0" cellpadding="0" border="0" style="border-collapse:collapse;background-color:#FFFFFF;border-top:0;border-bottom:0;">
<tbody>
<tr>
<td class="ecxpreheaderContainer" valign="top" style="padding-top:9px;"></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td valign="top" align="center" style="">
<table id="ecxtemplateHeader" width="600" cellspacing="0" cellpadding="0" border="0" style="border-collapse:collapse;background-color:#FFFFFF;border-top:0;border-bottom:0;">
<tbody>
<tr>
<td class="ecxheaderContainer" valign="top" style="">
<table class="ecxmcnImageBlock" width="100%" cellspacing="0" cellpadding="0" border="0" style="border-collapse:collapse;">
<tbody class="ecxmcnImageBlockOuter">
<tr>
<td class="ecxmcnImageBlockInner" valign="top" style="padding:9px;">
<table class="ecxmcnImageContentContainer" width="100%" cellspacing="0" cellpadding="0" border="0" align="left" style="border-collapse:collapse;">
<tbody>
<tr>
<td class="ecxmcnImageContent" valign="top" style="padding-right:9px;padding-left:9px;padding-top:0;padding-bottom:0;">
<a class="" style="word-wrap:break-word;" target="_blank" title="" href="http://www.hootpile.com">
<img class="ecxmcnImage" width="90" align="left" style="max-width:125px;padding-bottom:0;display:inline !important;vertical-align:bottom;border:0;text-decoration:none;-ms-interpolation-mode:bicubic;" src="http://www.hootpile.com/userdata/profile_pics/BqUht7I39izV6Fn/resized_2015-04-10_1620.png" alt="Hootpile">
</a>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td valign="top" align="center" style="">
<table id="ecxtemplateBody" width="600" cellspacing="0" cellpadding="0" border="0" style="border-collapse:collapse;background-color:#FFFFFF;border-top:0;border-bottom:0;">
<tbody>
<tr>
<td class="ecxbodyContainer" valign="top" style="">
<table class="ecxmcnTextBlock" width="100%" cellspacing="0" cellpadding="0" border="0" style="border-collapse:collapse;">
<tbody class="ecxmcnTextBlockOuter">
<tr>
<td class="ecxmcnTextBlockInner" valign="top" style="">
<table class="ecxmcnTextContentContainer" width="600" cellspacing="0" cellpadding="0" border="0" align="left" style="border-collapse:collapse;">
<tbody>
<tr>
<td class="ecxmcnTextContent" valign="top" style="padding-top:9px;padding-right:18px;padding-bottom:9px;padding-left:18px;color:#606060;font-family:Helvetica;font-size:15px;line-height:150%;text-align:left;">
<h1 class="ecxnull" style="padding:0;display:block;font-family:Helvetica;font-size:40px;font-style:normal;font-weight:bold;line-height:125%;letter-spacing:-1px;text-align:left;color:#606060 !important;">
<strong style="color:#000000;display:block;font-family:helvetica,arial,sans-serif;font-size:24px;font-weight:bold;line-height:30px;text-align:left;text-transform:none;">
<span style="font-size:22px;">
<span style="color:#333333;font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;line-height:1.6em;">Join Hootpile Now.</span>
</span>
</strong>
</h1>
<p style="padding:0;color:#606060;font-family:Helvetica;font-size:15px;line-height:150%;text-align:left;">
<span style="background-color:#FFFFFF;color:#000000;font-family:courier,courier new,monospace;font-size:15px;line-height:18px;text-align:left;">Hootpile is social utility that is transforming how students at VIT University connect with each other.</span>
<span style="color:#000000;font-family:courier,courier new,monospace;font-size:15px;line-height:18px;"> We believe that students should be provided with a common platform to discuss everything, build anything. Hootpile is free from advertising, manipulation and exploitation. </span>
<br>
<br>
<span style="color:#000000;font-family:courier,courier new,monospace;font-size:15px;line-height:18px;">We can all be in one place but it starts from you, Join Now!</span>
<br>
<br>
<span style="background-color:#FFFFFF;color:#000000;font-family:courier,courier new,monospace;font-size:15px;line-height:18px;text-align:left;">Simple, beautiful, and ad-free.</span>
<br>
</p>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<table class="ecxmcnButtonBlock" width="100%" cellspacing="0" cellpadding="0" border="0" style="border-collapse:collapse;">
<tbody class="ecxmcnButtonBlockOuter">
<tr>
<td class="ecxmcnButtonBlockInner" valign="top" align="left" style="padding-top:0;padding-right:18px;padding-bottom:18px;padding-left:18px;">
<table class="ecxmcnButtonContentContainer" cellspacing="0" cellpadding="0" border="0" style="border-collapse:separate !important;border:2px solid #418bbc;border-radius:0px;background-color:#418bbc;">
<tbody>
<tr>
<td class="ecxmcnButtonContent" valign="middle" align="center" style="font-size:16px;padding:15px;">
<a class="ecxmcnButton " style="font-weight:bold;letter-spacing:normal;line-height:100%;text-align:center;text-decoration:none;color:#FFFFFF;word-wrap:break-word;" target="_blank" href="http://www.hootpile.com" title="Go to Hootpile">Go to Hootpile.</a>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td valign="top" align="center" style="">
<table id="ecxtemplateFooter" width="600" cellspacing="0" cellpadding="0" border="0" style="border-collapse:collapse;background-color:#FFFFFF;border-top:0;border-bottom:0;">
<tbody>
<tr>
<td class="ecxfooterContainer" valign="top" style="padding-bottom:9px;">
<table class="ecxmcnTextBlock" width="100%" cellspacing="0" cellpadding="0" border="0" style="border-collapse:collapse;">
<tbody class="ecxmcnTextBlockOuter">
<tr>
<td class="ecxmcnTextBlockInner" valign="top" style="">
<table class="ecxmcnTextContentContainer" width="600" cellspacing="0" cellpadding="0" border="0" align="left" style="border-collapse:collapse;">
<tbody>
<tr>
<td class="ecxmcnTextContent" valign="top" style="padding-top:9px;padding-right:18px;padding-bottom:9px;padding-left:18px;color:#606060;font-family:Helvetica;font-size:11px;line-height:125%;text-align:left;">
<br>
<br>
<br>
<span style="font-size:14px;">
<span style="font-family:courier new,courier,lucida sans typewriter,lucida typewriter,monospace;">
<span>
Visit the
<a style="word-wrap:break-word;color:#606060;font-weight:normal;text-decoration:underline;" target="_blank" href="http://www.hootpile.com/manifesto">Hootpile Manifesto page.</a>
</span>
</span>
</span>
<br>
<br>
<br>
<br>
<span style="font-size:14px;">
<span style="font-family:courier new,courier,lucida sans typewriter,lucida typewriter,monospace;">
<strong>
<a style="word-wrap:break-word;color:#606060;font-weight:normal;text-decoration:underline;" target="_blank" href="http://www.hootpile.com">
<span style="color:#000000;">Hootpile.com</span>
</a>
</strong>
</span>
</span>
<br>
<br>
<br>
<br>
<span style="font-size:11px;">
<span style="font-family:courier new,courier,lucida sans typewriter,lucida typewriter,monospace;">
<span>
<span style="color:#D3D3D3;">If you dont want to receive </span>
<a target="_blank" style="word-wrap:break-word;color:#606060;font-weight:normal;text-decoration:underline;" href="http://ello.us3.list-manage2.com/unsubscribe?u=9ad48e023e0e67d4a8cda3fc9&id=eac7ac1a28&e=c73797a5f4&c=9d1407f6b5">
<span style="color:#D3D3D3;">emails</span>
</a>
<span style="color:#D3D3D3;">
from Hootpile
<br>
anymore, please
</span>
<a target="_blank" style="word-wrap:break-word;color:#606060;font-weight:normal;text-decoration:underline;" href="http://www.hootpile.com">
<span style="color:#D3D3D3;">unsubscribe here.</span>
</a>
<br>
<br>
<span style="color:#D3D3D3;">Hootpile, VIT University</span>
</span>
</span>
</span>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</center>
</body></html>';
$headers = "From: $from\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\n";
mail($to, $subject, $message, $headers);
}
?>
<form id="new_user" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" accept-charset="UTF-8" autocomplete="off">
<input type="submit" name="reg" value="send">
</form>
Use multiple time mail() function :
$to = "hootpile#gmail.com, hootpile2#gmail.com";
foreach(explode(',', $to) as $mail) {
mail(trim($mail), $subject, $message, $headers);
}
That will send an email for each user.
Notice: Use of undefined constant login - assumed 'login' in C:\wamp\www\Online_exam\header.php on line 43
Notice: Use of undefined constant login - assumed 'login' in C:\wamp\www\Online_exam\header.php on line 47
Notice: Use of undefined constant login - assumed 'login' in C:\wamp\www\Online_exam\index.php on line 30
I am new to PHP and learning SESSION, and i am trying to explore on that and i am receiving the above errors. Everything looks correct for me. Please somebody help me.
Index.php
<?php
session_start();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Wel come to Online Exam</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="quiz.css" rel="stylesheet" type="text/css">
</head>
<body>
<?php
include("header.php");
include("database.php");
extract($_POST);
if(isset($submit))
{
$rs=mysql_query("select * from mst_user where login='$loginid' and pass='$pass'");
if(mysql_num_rows($rs)<1)
{
$found="N";
}
else
{
$_SESSION[login]=$loginid;
}
}
if (isset($_SESSION[login]))
{
echo "<h1 class='style8' align=center>Wel come to Online Exam</h1>";
echo '<table width="28%" border="0" align="center">
<tr>
<td width="7%" height="65" valign="bottom"><img src="image/HLPBUTT2.JPG" width="50" height="50" align="middle"></td>
<td width="93%" valign="bottom" bordercolor="#0000FF"> Subject for Quiz </td>
</tr>
<tr>
<td height="58" valign="bottom"><img src="image/DEGREE.JPG" width="43" height="43" align="absmiddle"></td>
<td valign="bottom"> Result </td>
</tr>
</table>';
exit;
}
?>
<table width="100%" border="0">
<tr>
<td width="70%" height="25"> </td>
<td width="1%" rowspan="2" bgcolor="#CC3300"><span class="style6"></span></td>
<td width="29%" bgcolor="#CC3333"><div align="center" class="style1">User Login </div></td>
</tr>
<tr>
<td height="296" valign="top"><div align="center">
<h1 class="style8">Wel come to Online Quiz</h1>
<span class="style5"><img src="image/paathshala.jpg" width="129" height="100"><span class="style7"><img src="image/HLPBUTT2.JPG" width="50" height="50"><img src="image/BOOKPG.JPG" width="43" height="43"></span> </span>
<param name="movie" value="english theams two brothers.dat">
<param name="quality" value="high">
<param name="movie" value="Drag to a file to choose it.">
<param name="quality" value="high">
<param name="BGCOLOR" value="#FFFFFF">
<p align="left" class="style5"> </p>
<blockquote>
<p align="left" class="style5"><span class="style7">Wel Come to Online
exam. This Site will provide the quiz for various subject of interest.
You need to login for the take the online exam.</span></p>
</blockquote>
</div></td>
<td valign="top"><form name="form1" method="post" action="">
<table width="200" border="0">
<tr>
<td><span class="style2">Login ID </span></td>
<td><input name="loginid" type="text" id="loginid2"></td>
</tr>
<tr>
<td><span class="style2">Password</span></td>
<td><input name="pass" type="password" id="pass2"></td>
</tr>
<tr>
<td colspan="2"><span class="errors">
<?php
if(isset($found))
{
echo "Invalid Username or Password";
}
?>
</span></td>
</tr>
<tr>
<td colspan=2 align=center class="errors">
<input name="submit" type="submit" id="submit" value="Login"> </td>
</tr>
<tr>
<td colspan="2" bgcolor="#CC3300"><div align="center"><span class="style4">New User ? Signup Free</span></div></td>
</tr>
</table>
<div align="center">
<p class="style5"><img src="images/topleft.jpg" width="134" height="128"> </p>
</div>
</form></td>
</tr>
</table>
</body>
</html>
Header.php
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
}
-->
</style>
<table border="0" width="100%" cellspacing="0" cellpadding="0" background="image/topbkg.jpg">
<tr>
<td width="90%" valign="top">
<!--You can modify the text, color, size, number of loops and more on the flash header by editing the text file (fence.txt) included in the zip file.-->
<div align="left"><object classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000
codebase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,2,0
width=500
height=68>
<param name=movie value=image/fence.swf>
<param name=quality value=high>
<param name=BGCOLOR value=#000000>
<param name=SCALE value=showall>
<param name=wmode value=transparent>
<embed src=image/fence.swf
quality=high
pluginspage=http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash type=application/x-shockwave-flash
width=500
height=68
bgcolor=#000000
scale= showall>
</embed>
</object></div></td>
<td width="10%">
<img border="0" src="image/topright.jpg" width="203" height="68" align="right"></td>
</tr>
</table>
<table border="0" width="100%" cellspacing="0" cellpadding="0" bgcolor="#000000" background="img/blackbar.jpg">
<tr>
<td width="100%" align="right"><img border="0" src="image/blackbar.jpg" width="89" height="15"></td>
</tr>
</Table>
<Table width="100%">
<tr>
<td>
<?php "Hi ".$_SESSION[login]; ?>
</td>
<td>
<?php
if(isset($_SESSION[login]))
{
echo "<div align=\"right\"><strong> Home |Signout</strong></div>";
}
else
{
echo " ";
}
?>
</tr>
</table>
session variable should wrap with ' '...
change your session variable like this...
$_SESSION['session_var_name'];
and in your case it should..
$_SESSION['login']
You have to give the session name inside quotes only. Use
$_SESSION['login'] or $_SESSION["login"]
Non-numeric array key constants should be enclosed in quotes, either single or double. Otherwise, php thinks you are referring to a constant name. And since it's undefined, it falls back to guessing you just forgot the quotes...
That's why it works. And that's why the issue appears as a Notice. But in order to do away with it, change $_SESSION[login] to $_SESSION['login'].
Replace $_SESSION[login] into $_SESSION['login'] in all occurance of your code
<?php
session_start();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Wel come to Online Exam</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="quiz.css" rel="stylesheet" type="text/css">
</head>
<body>
<?php
include("header.php");
include("database.php");
extract($_POST);
if(isset($submit))
{
$rs=mysql_query("select * from mst_user where login='$loginid' and pass='$pass'");
if(mysql_num_rows($rs)<1)
{
$found="N";
}
else
{
$_SESSION['login']=$loginid;
}
}
if (isset($_SESSION['login']))
{
echo "<h1 class='style8' align=center>Wel come to Online Exam</h1>";
echo '<table width="28%" border="0" align="center">
<tr>
<td width="7%" height="65" valign="bottom"><img src="image/HLPBUTT2.JPG" width="50" height="50" align="middle"></td>
<td width="93%" valign="bottom" bordercolor="#0000FF"> Subject for Quiz </td>
</tr>
<tr>
<td height="58" valign="bottom"><img src="image/DEGREE.JPG" width="43" height="43" align="absmiddle"></td>
<td valign="bottom"> Result </td>
</tr>
</table>';
// exit;
}
?>
<table width="100%" border="0">
<tr>
<td width="70%" height="25"> </td>
<td width="1%" rowspan="2" bgcolor="#CC3300"><span class="style6"></span></td>
<td width="29%" bgcolor="#CC3333"><div align="center" class="style1">User Login </div></td>
</tr>
<tr>
<td height="296" valign="top"><div align="center">
<h1 class="style8">Wel come to Online Quiz</h1>
<span class="style5"><img src="image/paathshala.jpg" width="129" height="100"><span class="style7"><img src="image/HLPBUTT2.JPG" width="50" height="50"><img src="image/BOOKPG.JPG" width="43" height="43"></span> </span>
<param name="movie" value="english theams two brothers.dat">
<param name="quality" value="high">
<param name="movie" value="Drag to a file to choose it.">
<param name="quality" value="high">
<param name="BGCOLOR" value="#FFFFFF">
<p align="left" class="style5"> </p>
<blockquote>
<p align="left" class="style5"><span class="style7">Wel Come to Online
exam. This Site will provide the quiz for various subject of interest.
You need to login for the take the online exam.</span></p>
</blockquote>
</div></td>
<td valign="top"><form name="form1" method="post" action="">
<table width="200" border="0">
<tr>
<td><span class="style2">Login ID </span></td>
<td><input name="loginid" type="text" id="loginid2"></td>
</tr>
<tr>
<td><span class="style2">Password</span></td>
<td><input name="pass" type="password" id="pass2"></td>
</tr>
<tr>
<td colspan="2"><span class="errors">
<?php
if(isset($found))
{
echo "Invalid Username or Password";
}
?>
</span></td>
</tr>
<tr>
<td colspan=2 align=center class="errors">
<input name="submit" type="submit" id="submit" value="Login"> </td>
</tr>
<tr>
<td colspan="2" bgcolor="#CC3300"><div align="center"><span class="style4">New User ? Signup Free</span></div></td>
</tr>
</table>
<div align="center">
<p class="style5"><img src="images/topleft.jpg" width="134" height="128"> </p>
</div>
</form></td>
</tr>
</table>
</body>
</html>
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
}
-->
</style>
<table border="0" width="100%" cellspacing="0" cellpadding="0" background="image/topbkg.jpg">
<tr>
<td width="90%" valign="top">
<!--You can modify the text, color, size, number of loops and more on the flash header by editing the text file (fence.txt) included in the zip file.-->
<div align="left"><object classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000
codebase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,2,0
width=500
height=68>
<param name=movie value=image/fence.swf>
<param name=quality value=high>
<param name=BGCOLOR value=#000000>
<param name=SCALE value=showall>
<param name=wmode value=transparent>
<embed src=image/fence.swf
quality=high
pluginspage=http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash type=application/x-shockwave-flash
width=500
height=68
bgcolor=#000000
scale= showall>
</embed>
</object></div></td>
<td width="10%">
<img border="0" src="image/topright.jpg" width="203" height="68" align="right"></td>
</tr>
</table>
<table border="0" width="100%" cellspacing="0" cellpadding="0" bgcolor="#000000" background="img/blackbar.jpg">
<tr>
<td width="100%" align="right"><img border="0" src="image/blackbar.jpg" width="89" height="15"></td>
</tr>
</Table>
<Table width="100%">
<tr>
<td>
<?php
if(isset($_SESSION['login']))
{
print "Hi ".$_SESSION['login'];
}
?>
</td>
<td>
<?php
if(isset($_SESSION['login']))
{
echo "<div align=\"right\"><strong> Home |Signout</strong></div>";
}
else
{
echo " ";
}
?>
</tr>
</table>
Below is a contact us script in php, when I click submit at www.mydomain.com.au/contact.html it looks as though it works because I end up at ww.mydomain.com.au/thanks.html.
However the specified email account is not receiving contact emails.
Here is the code for the contact us script found at includes/contact_mail.php
<?php
if(isset($_POST['enter']) && $_POST['enter']==1)
{
$_SESSION['email']=$_POST['email'];
$to="name#domains.com";
$subject='Contact Us Details';
$message="<style>
.textstyle{
font-family:Tahoma;
font-size:11px;
color:#156E00;
text-align:left;
margin-left:10px;
text-decoration:none;
}
</style>";
$message.="<table width=400 border=0>
<tr><td class=textstyle>First Name: </td> <td class=textstyle>".$_POST['fname']."</td></tr>
<tr><td class=textstyle>Last Name: </td> <td class=textstyle>".$_POST['lname']."</td></tr>
<tr><td class=textstyle>E-mail: </td> <td class=textstyle>".$_POST['email']."</td></tr>
<tr><td class=textstyle>Phone Number: </td> <td class=textstyle>".$_POST['tel']."</td></tr>
<tr><td class=textstyle>Comments: </td> <td class=textstyle>".$_POST['que']."</td></tr>
</table>";
$mail_from = "From:".$_POST['email'];
$mail_from .="\r\nContent-type: text/html";
#mail($to,$subject,$message,$mail_from);
header("location: ../thankyou.html");
exit();
}
?>
Here is the code at ww.mydomain.com.au/contact.html
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="GENERATOR" content="Macromedia Dreamweaver CS3" />
<meta name="author" content="Relyon security" />
<meta name="keywords" content="Camera Surveillance,Spy Cameras,Remote Viewing,Audio recording,Relyon security" />
<meta name="description" content="" />
<meta http-equiv="EXPIRES" content="-1" />
<title>Relyon Security: About Relyon Security</title>
<link rel="stylesheet" type="text/css" href="css/stylesheet.css" />
<script language="JavaScript" type="text/javascript">
function fullcheck()
{
var str=document.contact.email.value;
//alert(str);
if (document.contact.fname.value=="")
{
alert ("Blank space not allowed. Please type your First Name.");
document.contact.fname.select();
return false;
}
if (document.contact.lname.value=="")
{
alert ("Blank space not allowed. Please type your Last Name.");
document.contact.lname.select();
return false;
}
if ((document.contact.email.value).indexOf(" ")>=0)
{
alert ("Blank space not allowed inside email!");
document.contact.email.select();
return false;
}
if (document.contact.email.value.indexOf("#",1) == -1)
{
alert("Invalid E-Mail address");
document.contact.email.focus();
document.contact.email.select();
return(false);
}
if (document.contact.email.value.indexOf("#") == 0)
{
alert("Invalid E-Mail address");
document.contact.email.focus();
document.contact.email.select();
return(false);
}
if (document.contact.email.value.indexOf(".",5) == -1)
{
alert("Invalid E-Mail address");
document.contact.email.focus();
document.contact.email.select();
return(false);
}
if (document.contact.email.value.indexOf(".") == 0)
{
alert("Invalid E-Mail address");
document.contact.email.focus();
document.contact.email.select();
return(false);
}
if ((document.contact.email.value.lastIndexOf(".")) -(document.contact.email.value.indexOf("#"))<4 )
{
alert("Invalid E-Mail address");
document.contact.email.focus();
document.contact.email.select();
return(false);
}
if (document.contact.tel.value=="")
{
alert ("Blank space not allowed. Please type your Telephone Number.");
document.contact.tel.select();
return false;
}
if (document.contact.que.value=="")
{
alert ("Blank space not allowed. Please enter your question or comment.");
document.contact.que.select();
return false;
}
}
//-->
</script>
</head>
<body>
<table width="1000" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td valign="top" align="left" width="110" height="186"><img src="images/spacer.gif" alt="" width="1" height="1" /></td>
<td width="780" rowspan="2" align="center" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="left">
<tr>
<td height="161" valign="top"><img src="images/spacer.gif" alt="" /></td>
</tr>
<tr>
<td valign="top" align="left" class="btn">
<table width="780" border="0" cellspacing="0" cellpadding="0" align="left">
<tr>
<td width="10" valign="top"><img src="images/btn-left.jpg" alt="" width="10" height="49" /></td>
<td align="center" valign="middle">
<table width="760" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td width="154" align="center" valign="top">Home Page</td>
<td width="180" align="center" valign="top">Our Services</td>
<td width="244" align="center" valign="top">About relyon security</td>
<td width="182" align="center" valign="top"><span class="navg_contact_activated">Contact Us</span></td>
</tr>
</table>
</td>
<td width="10" valign="top" align="right"><img src="images/btn-right.jpg" alt="" width="10" height="49" /></td>
</tr>
<tr>
<td colspan="3" height="1" bgcolor="#FFFFFF"><img src="images/spacer.gif" alt="" width="1" height="1" /></td>
</tr>
<tr>
<td width="10"><img src="images/left-bot.jpg" alt="" width="10" height="42" /></td>
<td class="shadow"><img src="images/spacer.gif" alt="" width="1" height="1" /></td>
<td><img src="images/rgh-bot.jpg" alt="" width="10" height="42" /></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
<td valign="top" align="left" width="110"><img src="images/spacer.gif" alt="" /></td>
</tr>
<tr>
<td valign="top" align="left" width="110" bgcolor="#FFFFFF" height="66"><img src="images/spacer.gif" alt="" /></td>
<td valign="top" align="left" width="110" bgcolor="#FFFFFF"><img src="images/spacer.gif" alt="" /></td>
</tr>
</table>
<table width="1000" border="0" cellspacing="0" cellpadding="0" align="center" class="white">
<tr>
<td valign="top" align="left"><table width="780" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td valign="top" class="inner_text"><span class="head-blue">Contact Us</span><br /><br />
Email address: relyonsecurity#live.com.au
<br />
Phone: 0422 663 489<br />
</td>
</tr>
</table>
</td>
</tr>
</table>
<table width="1000" border="0" cellspacing="0" cellpadding="0" align="center" class="blue">
<tr>
<td valign="top" align="left"><table width="780" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td valign="top">
<form name="contact" method="post" action="includes/contact_mail.php" onsubmit="return fullcheck()">
<table width="90%" border="0" cellpadding="0" cellspacing="3" >
<tr>
<td width="7%"> </td>
<td height="30" colspan="2" align="left" valign="middle"><span class="mandatory">*</span>Required fields</td>
</tr>
<tr>
<td> </td>
<td width="22%" class="form_text"><span class="mandatory">*</span>First Name :</td>
<td width="71%"><input name="fname" type="text" id="fname" size="35" class="inputbox"></td>
</tr>
<tr>
<td> </td>
<td width="22%" class="form_text"><span class="mandatory">*</span>Last Name :</td>
<td width="71%"><input name="lname" type="text" id="lname" size="35" class="inputbox"></td>
</tr>
<tr>
<td> </td>
<td class="form_text"><span class="mandatory">*</span>Email Address :</td>
<td><input name="email" type="text" class="inputbox" id="email" size="35"></td>
</tr>
<tr>
<td width="7%"> </td>
<td class="form_text"><span class="mandatory">*</span>Telephone Number:</td>
<td><input name="tel" type="text" class="inputbox" id="tel" size="35"></td>
</tr>
<tr>
<td> </td>
<td class="form_text"><span class="mandatory">*</span>Please enter your question or comment :</td>
<td><textarea name="que" cols="33" rows="8" id="que" class="inputbox"></textarea></td>
</tr>
<tr>
<td colspan="3" height="5" valign="top"><input name="enter" type="hidden" value="1" /></td>
</tr>
<tr>
<td> </td>
<td class="form_text"> </td>
<td><input type="submit" name="Submit" value="Submit" class="inputbox">
<input type="reset" name="Submit2" value="Reset" class="inputbox"></td>
</tr>
<tr>
<td colspan="3" height="30" valign="top"></td>
</tr>
</table>
</form>
<table width="780" border="0" cellspacing="0" cellpadding="0" align="center" class="footer" height="41">
<tr>
<td valign="top" width="12" height="8"><img src="images/foo-l-top.gif" alt="" width="12" height="8" /></td>
<td><img src="images/spacer.gif" alt="" /></td>
<td align="right" valign="top" width="9" height="8"><img src="images/foo-r-top.gif" alt="" width="9" height="8" /></td>
</tr>
<tr>
<td><img src="images/spacer.gif" alt="" /></td>
<td align="center" valign="middle">©2009 Relyon Security.com All Rights Reserved</td>
<td><img src="images/spacer.gif" alt="" /></td>
</tr>
<tr>
<td valign="bottom" height="8"><img src="images/foo-l-bot.gif" alt="" width="12" height="8" /></td>
<td><img src="images/spacer.gif" alt="" /></td>
<td valign="bottom"><img src="images/foo-r-bot.gif" alt="" width="9" height="8" /></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
Second attempt at script?
<?php
error_reporting(E_ALL)
if(isset($_POST['enter']) && $_POST['enter']==1)
{
$_SESSION['email']=$_POST['email'];
$to="name#domains.com";
$subject='Contact Us Details';
$message="<style>
.textstyle{
font-family:Tahoma;
font-size:11px;
color:#156E00;
text-align:left;
margin-left:10px;
text-decoration:none;
}
</style>";
$message.="<table width=400 border=0>
<tr><td class=textstyle>First Name: </td> <td class=textstyle>".$_POST['fname']."</td></tr>
<tr><td class=textstyle>Last Name: </td> <td class=textstyle>".$_POST['lname']."</td></tr>
<tr><td class=textstyle>E-mail: </td> <td class=textstyle>".$_POST['email']."</td></tr>
<tr><td class=textstyle>Phone Number: </td> <td class=textstyle>".$_POST['tel']."</td></tr>
<tr><td class=textstyle>Comments: </td> <td class=textstyle>".$_POST['que']."</td></tr>
</table>";
$mail_from = "From:".$_POST['email'];
$mail_from .="\r\nContent-type: text/html";
mail($to,$subject,$message,$mail_from);
// header("location: ../thankyou.html");
exit();
}
?>
put error_reporting(E_ALL) at the top of the script, remove # from mail() call and comment string with header() and THEN look for errors
I have the following site and I want with regular expressions to get the text between the following tags
<td colspan="2" align="left" valign="top" bgcolor="#FBFAF4"> ..... </td>
I am trying with the following however it returns an empty array of $matches.
preg_match_all("/<td(.*) bgcolor=\"#FBFAF4\"\>(.*)\<\/td>/",$old_filecontents,$matches);
Which is the correct pattern for this?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Exotiq - Ðñïúüíôá</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-7"> <link href="Styles.css" rel="stylesheet" type="text/css"> <link href="stylesheets/Styles.css" rel="stylesheet" type="text/css"> <script src="scripts/PopBox.js" type="text/javascript"></script> <script type="text/javascript"> popBoxWaitImage.src = "images/spinner40.gif"; popBoxRevertImage = "images/magminus.gif"; popBoxPopImage = "images/magplus.gif"; </script> <script type="text/javascript"> AC_FL_RunContent('codebase', 'http://download.macromedia.com/pub/shockwave/ cabs/flash/swflash.cab#version=9,0,28,0', 'width','675','height','445','title','Morpork', 'src','assets/flash/morepork','loop', 'false','quality','high','pluginspage', 'http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash', 'wmode','transparent','movie','assets/flash/morepork'); </script> </head> <body background="images/fonto2.jpg" topmargin="0"> <table width="948" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td><table width="948" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="24"> </td> <td height="150" colspan="3"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="900" height="150"> <param name="movie" value="flash/top02.swf"> <param name="quality" value="high"> <param name="wmode" value="transparent"> <embed src="flash/top02.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="900" height="150"></embed></object></td> <td width="24" height="150"> </td> </tr> <tr> <td height="31" colspan="5" valign="middle"> <div align="center"> <script src="menu/xaramenu.js"></script> <script Webstyle4 src="menu/menu_.js"></script> </div></td> </tr> <tr> <td width="24"> </td> <td width="200" valign="top" background="images/GreenFasa.jpg"> <br> <table width="180" border="0" align="center" cellpadding="0" cellspacing="1"> <tr> <td height="25" class="styles"> Makuti<br> <hr> </td> </tr> <tr> <td height="25" class="styles"> Fun Palm<br> <hr> </td> </tr> <tr> <td height="25" class="styles"> Alang-Alang<br> <hr> </td> </tr> <tr> <td height="25" class="styles"> Thatch<br> <hr> </td> </tr> <tr> <td height="25" class="styles"> <strong>Abaca</strong><br> <hr> </td> </tr> <tr> <td height="25" class="styles"> </td> </tr> </table></td> <td colspan="2" align="left" valign="top" bgcolor="#FBFAF4"> <div align="left"> <table width="680" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="600" height="40" class="titles">ÊáôáóêåõÝò - ÏìðñÝëåò - Abaca</td> <td width="50" align="right" valign="middle" class="titles"> <div align="right"><img src="images/uk-flag.jpg" width="30" height="17" border="0"></div></td> </tr> <tr> <td colspan="2" class="body"><p>Ç ïìðñÝëá <strong>Abaca</strong> Ýñ÷åôáé ùò Üîéïò áíôéêáôáóôÜôçò ôçò ïìðñÝëáò Rattan ðïõ åðß 15 ÷ñüíéá óôïëßæåé ôéò åëëçíéêÝò ðáñáëßåò. Ôï <strong>Abaca</strong> åßíáé Ýíá öõóéêü õëéêü ðéï <strong>áíèåêôéêü</strong> êáé ðéï üìïñöï áðü ôï Rattan. <br> Ðáñáäßäåôáé ìå <strong>îýëéíï êïñìü åìðïôéóìïý</strong> Ö8åê.<br> <br> </p> <table width="680" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="340" height="150" valign="middle"> <div align="left"><img src="images/Manufactures/Umbrelas/Abaca/AbacaUmbrela.jpg" width="328" height="500"></div></td> <td width="340" height="150" valign="bottom" class="body"> <table width="340" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="170" height="130"> <div align="center"><img src="images/Manufactures/Umbrelas/Abaca/1_Abaca02_s.jpg" width="152" height="101" class="PopBoxImageSmall" onclick="Pop (this,50,'PopBoxImageLarge');" title="ÌåãÝèõíóç" pbsrc="images/Manufactures/Umbrelas/Abaca/1_Abaca02.jpg" pbCaption="Abaca - ÏìðñÝëá ðáñáëßáò" popBoxCaptionBelow="true" /></div></td> <td width="170" height="130"> <div align="center"><img src="images/Manufactures/Umbrelas/Abaca/2_Abaca03_s.jpg" width="150" height="112" class="PopBoxImageSmall" onclick="Pop (this,50,'PopBoxImageLarge');" title="ÌåãÝèõíóç" pbsrc="images/Manufactures/Umbrelas/Abaca/2_Abaca03.jpg" pbCaption="Abaca - ÏìðñÝëá ðáñáëßáò" popBoxCaptionBelow="true" /></div></td> </tr> <tr> <td width="170" height="130"> <div align="center"><img src="images/Manufactures/Umbrelas/Abaca/3_Abaca01_s.jpg" width="150" height="112" class="PopBoxImageSmall" onclick="Pop (this,50,'PopBoxImageLarge');" title="ÌåãÝèõíóç" pbsrc="images/Manufactures/Umbrelas/Abaca/3_Abaca01.jpg" pbCaption="Abaca - ÏìðñÝëá ðáñáëßáò" popBoxCaptionBelow="true" /></div></td> <td width="170" height="130"> <div align="center"></div></td> </tr> <tr> <td width="170" height="130"> <div align="center"></div></td> <td width="170" height="130"> <div align="center"></div></td> </tr> <tr> <td width="170" height="130"> <div align="center"></div></td> <td width="170" height="130"> <div align="center"></div></td> </tr> </table></td> </tr> <tr> <td width="340" height="50" valign="top"> <p align="center"> </p></td> <td width="340" height="50" valign="top"> <div align="center" class="perigrafes">ÊëéêÜñåôáé ðÜíù óôéò öùôïãñáößåò ãéá ìåãÝèõíóç</div></td> </tr> <tr> <td width="340" valign="bottom"> <div align="center"> </div></td> <td width="340" valign="bottom"> <p align="center"> </p></td> </tr> <tr> <td width="340" valign="top"> <div align="center"></div></td> <td width="340" valign="top"> <p align="center"> </p></td> </tr> <tr> <td height="20" colspan="2" valign="top"> </td> </tr> </table></td> </tr> </table> <font color="#FFFFFF"></font></div></td> <td width="24" height="420"> </td> </tr> <tr> <td width="24"> </td> <td width="200"> </td> <td width="600"> </td> <td width="100"> </td> <td width="24"> </td> </tr> </table></td> </tr> <tr> <td height="22"><table width="900" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#007F3E"> <tr> <td height="25"> <div align="center" class="styles">All rights reserved ® Designed by CONTINENTAL ADVERTISING </div></td> </tr> </table></td> </tr> </table> <script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); </script> <script type="text/javascript"> try { var pageTracker = _gat._getTracker("UA-12742174-1"); pageTracker._trackPageview(); } catch(err) {}</script> </body> </html>
Given that the cell you're talking about contains HTML, another table in fact, you can't do traditional termination checking ... or you'll get the content between the cell opening and the first </td> you find. Plus '.' isn't multi-line friendly, so unless your cell opens and terminates on the same line, you'll get no matches.
I'd say don't use regular expressions for this. Try an XML parser.
If you were just getting plain text, that'd be fine, but because you're returning HTML which contains your terminator, you'll need to use a parser with some kind of DOM depth awareness ... ... or find a way to count terminators in regex.