Ok so I found an ajax contact form script but i can't get the b****** to work. I made a bunch of alterations to it and it didn't work so i replaced everything with the original and it still didn't work...dunno why, but anyhow. The form appears after a delay on the page in a hidden DIV. The original form just had name, email and message, but i have to add a few questions to it so i did and i also added some code from another script i found to alter the body text. I probably screwed it all up but i'm no expert so please help.
All the code is in a single php file that's called as an include in the actual page. It displays just fine but when i go to submit it just says "please wait" and never sends an email. - <?
-
if(!isset($rnd) || !isset($name) || !isset($email) || !isset($realtor) || !isset($when) || !isset($selling)) {
-
showform();
-
} else {
-
processform();
-
}
-
-
$Body = "";
-
$Body .= "Name: ";
-
$Body .= $Name;
-
$Body .= "\n";
-
$Body .= "Email: ";
-
$Body .= $email;
-
$Body .= "\n";
-
$Body .= "Working with a Realtor: ";
-
$Body .= $Realtor;
-
$Body .= "\n";
-
$Body .= "How soon they are looking to buy or rent: ";
-
$Body .= $When;
-
$Body .= "\n";
-
$Body .= "Selling their home: ";
-
$Body .= $Selling;
-
$Body .= "\n";
-
-
function processform(){
-
global $name, $email, $realtor, $when, $selling, $Body;
-
-
$email_to1 = "shadedjg@hotmail.com"; // enter your email here
-
$email_from1 = $mail;
-
$email_to2 = $mail;
-
$email_from2 = $email_to1;
-
$email_subject = "Contact Form: ".stripslashes($subject);
-
$email_message = "Please find below a message submitted by '".stripslashes($name);
-
$email_message .="' on ".date("d/m/Y")." at ".date("H:i")."nn";
-
$email_message .="--------- START OF SUBMITTED MESSAGE ---------nn";
-
$email_message .= stripslashes($Body);
-
$email_message .="nn--------- END OF SUBMITTED MESSAGE ---------nn";
-
-
$confirmation_subject = "Thank you for your message";
-
$confirmation = "This is to confirm we have received your message....";
-
-
// SEND EMAIL TO email_to2 - confirmation
-
$headers = 'From: '.$email_from2."rn" .
-
'Reply-To: '.$email_from2."rn" .
-
'X-Mailer: PHP/' . phpversion();
-
-
mail($email_to2, $email_subject, $confirmation, $headers);
-
-
// SEND EMAIL TO email_to1 - message to you!!
-
$headers = 'From: '.$email_from1."rn" .
-
'Reply-To: '.$email_from1."rn" .
-
'X-Mailer: PHP/' . phpversion();
-
-
mail($email_to1, $email_subject, $email_message, $headers);
-
-
echo "Thank You.";
-
die();
-
} // end processform()
-
-
function showform() {
-
?>
-
<STYLE type="text/css">
-
div.row {
-
clear:both;
-
}
-
div.row span.label {
-
float: left;
-
width: 60px;
-
text-align: right;
-
}
-
div.row span.formw {
-
float: right;
-
width: 220px;
-
text-align: left;
-
}
-
div.row span.left {
-
float: left;
-
text-align: left;
-
font-weight: bold;
-
color: #fff;
-
width: 49%;
-
}
-
div.row span.right {
-
float: right;
-
text-align: right;
-
font-weight: bold;
-
color: #fff;
-
width: 49%;
-
}
-
div.row span.submit{
-
width:280px;
-
text-align:center;
-
}
-
#form{
-
width: 300px;
-
height: 500px;
-
background-color: #f6f6f6;
-
border: 1px dotted #666;
-
padding: 2px;
-
margin: 0px auto;
-
position: relative;
-
}
-
#confirmation{
-
width: 300px;
-
height:220px;
-
background-color: #f6f6f6;
-
border: 1px dotted #666;
-
padding: 2px;
-
margin: 0px auto;
-
text-align: center;
-
font-weight: bold;
-
}
-
</STYLE>
-
<script type="text/javascript">
-
<!--
-
var http = createRequestObject();
-
var areal = Math.random() + "";
-
var real = areal.substring(2,6);
-
-
function createRequestObject() {
-
var xmlhttp;
-
try { xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); }
-
catch(e) {
-
try { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}
-
catch(f) { xmlhttp=null; }
-
}
-
if(!xmlhttp&&typeof XMLHttpRequest!="undefined") {
-
xmlhttp=new XMLHttpRequest();
-
}
-
return xmlhttp;
-
}
-
-
function sendRequest() {
-
var rnd = Math.random();
-
var name = escape(document.getElementById("name").value);
-
var email = escape(document.getElementById("email").value);
-
var realtor = escape(document.getElementById("realtor").value);
-
var when = escape(document.getElementById("when").value);
-
var selling = escape(document.getElementById("selling").value);
-
-
try{
-
http.open('POST', 'ajax_contact.php');
-
http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
-
http.onreadystatechange = handleResponse;
-
http.send('name='+name+'&email='+email+'&realtor='+realtor+'&when='+when+'&selling='+selling+'&rnd='+rnd);
-
}
-
catch(e){}
-
finally{}
-
}
-
-
function check_values() {
-
var valid = document.getElementById("valid").value;
-
if(real !== valid) {
-
alert("Anti-Bot check failed.....nPlease enter the 4 digits as they appear.");
-
return false;
-
}
-
-
var name = document.getElementById("name").value;
-
var email = document.getElementById("email").value;
-
var realtor = document.getElementById("realtor").value;
-
var when = document.getElementById("when").value;
-
var selling = document.getElementById("selling").value;
-
if(trim(name) == "" ||
-
trim(email) == "" ||
-
trim(realtor) == "" ||
-
trim(when) == "" ||
-
trim(selling) == "") {
-
alert("Please complete all fields");
-
} else {
-
if(isEmail(email)) {
-
document.getElementById("submit").disabled=true;
-
document.getElementById("submit").value='Please Wait..';
-
sendRequest();
-
} else {
-
alert("Email appears to be invalid.nPlease check.");
-
document.getElementById("email").focus();
-
document.getElementById("email").select();
-
}
-
}
-
}
-
-
function handleResponse() {
-
try{
-
if((http.readyState == 4)&&(http.status == 200)){
-
var response = http.responseText;
-
document.getElementById("confirmation").innerHTML = response;
-
document.getElementById("confirmation").style.display ="";
-
document.getElementById("form").style.display = "none";
-
}
-
}
-
catch(e){}
-
finally{}
-
}
-
-
function isUndefined(a) {
-
return typeof a == 'undefined';
-
}
-
-
function trim(a) {
-
return a.replace(/^s*(S*(s+S+)*)s*$/, "$1");
-
}
-
-
function isEmail(a) {
-
return (a.indexOf(".") > 0) && (a.indexOf("@") > 0);
-
}
-
-
function botCheckInfo() {
-
alert("To prevent automatic programs (bots)nfrom submitting spam through this form,nwe have added a simple validationncheck to the form. You must enter nthese 4 digits in the box provided innorder to submit the form.");
-
}
-
// -->
-
</script>
-
-
<?
-
} // end showform()
-
?>
-
<div id="form">
-
<form>
-
<div class="row"><span class="label">Name:</span>
-
<span class="formw"><input type="text" id="name" size="30" /></span></div>
-
<div class="row"><span class="label">Email:</span>
-
<span class="formw"><input type="text" id="email" size="30" /></span></div>
-
<div class="row"><span class="label">Are your currently working with a Realtor?:</span>
-
<span class="formw"><select id="realtor">
-
<option value="Yes">Yes</option>
-
<option value="No">No</option>
-
</select></span></div>
-
<div class="row"><span class="label">How soon are you looking to buy, sell or rent?:</span>
-
<span class="formw"><select id="when">
-
<option value="Now">Now</option>
-
<option value="Within a few months">Within a few months</option>
-
<option value="Within 6 months">Within 6 months</option>
-
<option value="Within a year">Within a year</option>
-
<option value="Not sure">Not sure</option>
-
</select></span></div>
-
<div class="row"><span class="label">Do you have to sell your home?:</span>
-
<span class="formw"><select id="selling">
-
<option value="Yes">Yes</option>
-
<option value="No">No</option>
-
</select></span></div>
-
<div class="row"><a href="javascript:botCheckInfo()">Anti-bot check</a>. Enter Digits '<b><script language="javascript">document.write(real)</script></b>' below:</div>
-
<div class="row"><input type="text" id="valid" size="15" /></div>
-
<div class="row"> </div>
-
<div class="row">
-
<input type="button" value="Submit" id="submit" onClick="return check_values();"></div>
-
<div id="confirmation" style="display:none"></span></div>
-
</form>
-
-
</div>
Dec 8 '07
12 3830
I finally figured it out. It was ONE character. The line where the javasript sends the variables to the php portion had a '$' instead of '&' on one of them. Prime example of why i'm not a coder :oP
Thanks for all your help :o) Much appreciated.
gits 5,390
Recognized Expert Moderator Expert
*lol* ... nope ... believe me ... such errors are common ... lasty i had such a problem at work ... a colleague searched for a bug and we did together ... it lasts us two hours to find out a mistyped check if (val1 = val2) as an assignment ... we overlooked it every time ... glad to hear you found the error ;)
kind regards
acoder 16,027
Recognized Expert Moderator MVP
I finally figured it out. It was ONE character. The line where the javasript sends the variables to the php portion had a '$' instead of '&' on one of them.
In your code in post #1, there's no $, but it must've accidentally been added by the time you got to post #7.
Prime example of why i'm not a coder :oP
Thanks for all your help :o) Much appreciated.
As gits said, it doesn't mean you're not a coder. Glad you got it working and good luck with your project.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Jean-Philippe Encausse |
last post by:
Hi,
I got 2 bugs using AJAX with ISO-8859-1:
1. While serializing form's value using prototype.js I lost accent
éàè ... because it use encodeURIComponent() function. I saw on
google, for ISO-8859-1 encoding I have to use escape(). It works fine
!
2. While receving content from AJAX Request with header <?xml
|
by: Joel Byrd |
last post by:
I want a website that works in the following way: It has a main
content div, and of course menu items. When you click a menu item, it
should use AJAX to change the main content div to the content of the
page of the menu item you clicked. So, for example, if you clicked
"About Us", then in the main content div, you would see the content of
the about us page. Now, this is pretty simple if the content of a
given page is just text (I just...
|
by: Eric Wallstedt |
last post by:
I have a page that "logs" changes made to input fields using ajax to
pass data to a cgi. I use POST and it works fine most of the time (all
the time in IE). But it fails when I get the data from a popup that
invokes a function that in turn invokes ajax.
Scenerio
1. user clicks a button to create a popup
2. the user selects a select member and clicks a button and a
|
by: www.web20developers.com |
last post by:
http://www.web20developers.com
http://www.web20developers.com/index.php?option=com_content&task=view...
Ajallerix : AJAX, simple, fast Web image gallery demo ; at Novell
AJAX - microlink pattern tutorial : A microlink is a link that opens up
|
by: jobo |
last post by:
I have a news section of the website contained within the updatepanel.
What I want is that when a news summary is clicked, the news item
opens up in that same box. I thought I wired everything up correctly
so that it did not do a postback. But when I walked through the
execution process, it in fact does cause a postback when the "expand"
event is raised. Why does this happen? Can someone help me? Thanks.
Here is the .aspx part
| |
by: jrnail23 |
last post by:
I have a user control which contains an UpdatePanel, which contains a
MultiView inside, with a GridView in one of the views.
In my GridView, I have a ButtonField which is supposed to trigger a
server-side operation, using the RowCommand functionality.
In IE, this all works great, but in Firefox (v2.0.0.6), clicking the
above mentioned ButtonField fires off two similar AJAX requests, which
is causing errors in my server-side code.
...
|
by: shivendravikramsingh |
last post by:
hi friends, i m using a ajax function for retrieving some values from a database table,and display the values in required field,my prob is that the ajax function i m using is working f9 once,but if i change something in php file using in ajax function.it not refreshed,means its shows the previous result it not get updated.i can't understand whats the prob.this is the code i m using:
<?
include("config.inc.php");
//error_reporting(0); ...
|
by: dhsieh |
last post by:
I am trying out nested AJAX calls for the first time, but I seem to have hit a snag. The code snippet is the outer AJAX call and a function, it gathers information about a company.
As we get towards the bottom of the onComplete function, there is a call to doGetAddressContacts(), which accepts an address ID. This then returns a list of contacts at that address.
What I am trying to do is for each address that it retrieves and outputs, as it...
|
by: ToddFur |
last post by:
I see several postings on this but I am still unable to figure out my problem. I can pass the values of my text field but not radio button (or even checkboxes).
My PHP file
<?php
//declare our variables
$day = $_GET;
$date = $_GET;
$groupname = $_GET;
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |