Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: A contact form

  1. #1
    Join Date
    Feb 2004
    Posts
    1,085

    Default A contact form

    I thought I would share the contact form I just tested.

    Email from site with some required fields.

    I placed comments throughout the file for help.


    Can be seen http://michaelmcgorman.com/contactus.php

    hit submit the first time to see the required fields test.

    Also note: the phone will autotab and the zip will autotab.

    other than that a typical PHP mail script.
    Attached Files Attached Files

  2. #2
    Join Date
    Jun 2004
    Posts
    93

    Default

    Thanks....I'll give this a look because I was not happy with the one I was using and this looks great from what I've seen so far

  3. #3
    Join Date
    Nov 2003
    Location
    NYC
    Posts
    115

    Default

    good job !

  4. #4
    Join Date
    May 2005
    Posts
    8

    Default

    has this can this be adapted for 2.0?

  5. #5
    Join Date
    Feb 2004
    Posts
    1,085

    Default

    I've not figured out how to accomplish this.

  6. #6

    Default Re: A contact form

    Is it possible to pass a "to:" email address to the form?

    I want to create a dynamic link on all of my listings so people can contact the agent through the website.

    Has anyone tried this?
    Last edited by jaredwein; 10-04-2005 at 01:47 PM.
    http://www.EastLansingRentals.com :: Providing Cheap and Easy Rental Listings to the residents of East Lansing, Michigan and it's surrounding areas.

  7. #7

    Default Re: A contact form

    OK, an update of sorts.

    I am still trying to get a dynamic link made with the contactus.php page so links can be made that send emails to different addresses.

    I have created a getListingRaw($listingID) function. Here is the code:

    Code:
    function getListingEmailRaw($listingID)
    	{
    		// get the email address for the person who posted a listing
    		global $conn, $lang, $config;
    		$listingID = make_db_extra_safe($listingID);
    		$sql = "SELECT " . $config[table_prefix] . "UserDB.emailAddress FROM " . $config[table_prefix] . "listingsDB, " . $config[table_prefix] . "UserDB WHERE ((" . $config[table_prefix] . "listingsDB.ID = $listingID) AND (" . $config[table_prefix] . "UserDB.ID = " . $config[table_prefix] . "listingsDB.user_ID))";
    		$recordSet = $conn->Execute($sql);
    		if ($recordSet === false)
    		{
    			log_error($sql);
    		}
    		// return the email address
    		while (!$recordSet->EOF)
    		{
    			$listing_emailAddress = make_db_unsafe ($recordSet->fields[emailAddress]);
    			$recordSet->MoveNext();
    		} // end while
    		echo "$listing_emailAddress";
    	} 
    // function getListingEmailRaw
    Here is the link that I am using on my pages:
    Code:
    <a href="contactagent.php?toAddress=&#60;<?php getListingEmailRaw($listingID) ?>&#62;&mls=<? renderSingleListingItemRaw($listingID, "mls") ?>
    Now, when I pull up the page and use for example,
    Code:
    http://www.century21hometowne.com/or115/contactagent.php?toAddress=%3Cjared@century21hometowne.com%3E&mls=123859
    or
    Code:
    http://www.century21hometowne.com/or115/contactagent.php?toAddress=jared@century21hometowne.com&mls=123859
    it doesn't work.

    It comes back with an error that there is no email address specified in the header. I have commented out the other email addresses, but left the $toAddress variable in, which is defined in the address bar.

    Will this work?
    http://www.EastLansingRentals.com :: Providing Cheap and Easy Rental Listings to the residents of East Lansing, Michigan and it's surrounding areas.

  8. #8

    Default Re: A contact form

    bump .....
    http://www.EastLansingRentals.com :: Providing Cheap and Easy Rental Listings to the residents of East Lansing, Michigan and it's surrounding areas.

  9. #9

    Default Re: A contact form

    I have the solution, I will post in a couple minutes

    UPDATE:

    Instead of using the contactus.php, I ended up using the email_listing.php which comes with OR.

    Four files will need to be updated.

    email_listing.php
    Code:
    <?php
    	include("include/common.php");
    	include("$config[template_path]/user_top.html");
    	global $conn, $config, $lang;
    
    	if ($listingID != "")
    
    	{
    
    		if ($action == "mail")
    
    		{
    
    			if ($to == "")
    			{
    				echo ("<h3>$lang[email_listing_provide_email]</h3> ");
    				include("$config[template_path]/user_bottom.html");
    				exit;
    			}
    
    			if ($sender == "")
    			{
    				echo ("<h3>$lang[email_listing_enter_name]</h3>");
    				include("$config[template_path]/user_bottom.html");
    				exit;
    			}
    
    			if ($sender_email == "")
    			{
    				echo ("<h3>$lang[email_listing_enter_email_address]</h3>");
    				include("$config[template_path]/user_bottom.html");
    				exit;
    			}
    
    			$message = $lang[email_listing_default_message];
    
    			$message = stripslashes($message);
    
    			$header = "From: ".$sender." <".$sender_email.">\r\n";
    			$header .= "X-Sender: $config[admin_email]\r\n";
    			$header .= "Return-Path: $config[admin_email]\r\n";
    
    			if($agent!=1){
    			$temp = mail($to, $lang[email_listing_default_subject], $message, $header) or print "<h3>Could not send mail.</h3>"; 
    			}
    			else{
    			$temp = mail($to, $lang[email_listing_agent_subject], $message, $header) or print "<h3>Could not send mail.</h3>"; 
    			}
    
    			if ($temp = true)
    			{
    				echo "$lang[email_listing_sent] $to.<P><a href=\"listingview.php?listingID=$listingID\">Return to listing</a>   ";
    			}
    
    		}
    
    		else
    
    		{
    			if($to=="")
    			{
    			echo "<h3>$lang[email_listing_send_listing_to_friend]</h3>";
    			}
    			else{
    			echo "<h3>Ask A Question About This Listing...</h3>";
    			}
    			
    			echo "<form name=\"mailman\" action=\"email_listing.php\" method=\"post\"> ";
    			echo "<table border=\"0\" cellpadding=2 cellspacing=0>";
    			if($to==""){
    			echo "<input type=\"hidden\" name=\"agent\" value=\"0\">";
    			echo "<tr><td width=\"120\" align=center>$lang[email_listing_friend_email]:</td><td align=left><input type=text name=\"to\"></td></tr>";
    			}
    			else{
    			echo "<input type=\"hidden\" name=\"agent\" value=\"1\">";
    			echo "<input type=\"hidden\" name=\"to\" value=\"$to\">";
    			}
    			
    			echo "<tr><td width=\"120\" align=center>$lang[email_listing_your_name]:</td><td align=left><input type=text name=\"sender\"></td></tr>";
    			echo "<tr><td width=\"120\" align=center>$lang[email_listing_your_email]:</td><td align=left><input type=text name=\"sender_email\"></td></tr>";
    
    			echo "<tr><td width=\"120\" align=center>$lang[email_listing_your_message]:</td><td align=left><textarea name=\"comment\" cols=60 rows=4></textarea></td></tr>";
    			echo "<input type=\"hidden\" name=\"action\" value=\"mail\">";
    			echo "<input type=\"hidden\" name=\"listingID\" value=\"$listingID\">";
    			echo "<tr><td></td><td align=\"middle\"><input type=\"submit\" value=\"$lang[email_listing_send]\"></td></tr>";
    			echo "</table></form>";
    
    		} // end else action != mail
    
    	} // end ($listingID != "")
    
    	else
    
    	{
    
    		echo "<h3>You must have something to email!</h3>";
    
    	}
    
    		
    
    	include("$config[template_path]/user_bottom.html");
    
    ?>
    listingview.php (add this code on it somewhere)
    Code:
    <a href="email_listing.php?listingID=<?php echo $listingID ?>&amp;to=<?php getListingEmailRaw($listingID) ?>"><b>Ask The Agent A Question</b></a><br>
    style.php (add this function)
    Code:
    function getListingEmailRaw($listingID)
    	{
    		// get the email address for the person who posted a listing
    		global $conn, $lang, $config;
    		$listingID = make_db_extra_safe($listingID);
    		$sql = "SELECT " . $config[table_prefix] . "UserDB.emailAddress FROM " . $config[table_prefix] . "listingsDB, " . $config[table_prefix] . "UserDB WHERE ((" . $config[table_prefix] . "listingsDB.ID = $listingID) AND (" . $config[table_prefix] . "UserDB.ID = " . $config[table_prefix] . "listingsDB.user_ID))";
    		$recordSet = $conn->Execute($sql);
    		if ($recordSet === false)
    		{
    			log_error($sql);
    		}
    		// return the email address
    		while (!$recordSet->EOF)
    		{
    			$listing_emailAddress = make_db_unsafe ($recordSet->fields[emailAddress]);
    			$recordSet->MoveNext();
    		} // end while
    		echo "$listing_emailAddress";
    	} 
    // function getListingEmailRaw
    include\language\english.php (add this to the email section)
    Code:
    $lang['email_listing_agent_subject'] = "Century21HomeTowne.com Listing Question";
    In the language file, in $lang['email_listing_default_message'] you may also want to change "Your friend, $sender, has sent along" to "$sender has sent along"

    Let me know if you have any problems.
    Last edited by jaredwein; 11-08-2005 at 01:26 PM. Reason: added the code
    http://www.EastLansingRentals.com :: Providing Cheap and Easy Rental Listings to the residents of East Lansing, Michigan and it's surrounding areas.

  10. #10
    Join Date
    Oct 2005
    Posts
    16

    Default Re: A contact form

    Hi... jaredwein

    I am trying to make a contact form, to make i possible to send sms to agents. Instead of sending a normal email. We need to send the email to our smsgateway, and the adress will look like this: 29272759@sms.mutax.com (the phone number is the agents mobil number) -and the gateway will automatically send this email as a normal sms.
    I think (with some modifikations) your contact form is exactely what we need.
    But i can't guess where to put the first part of the code: email_listing.php - I can't find a file called "email_listing.php". (Using OR/Mamboor ver. 2.1.1) Is it a part of another .php file?

    Could you please advise me -how to?

    Best regards -and thanks in advance

    Boris - Denmark

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •