Hello Everyone :)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Skrilla
Forum Newbie
Posts: 9
Joined: Sun Apr 25, 2010 11:26 am

Hello Everyone :)

Post by Skrilla »

Hi I'm new around here and could use some help :P

I am building a pretty simple contact form and can't get it to send the email for some reason.
I have created many forms with this exact same code but this time have added allot more fields and checkboxes.. It has always worked before but this is the first time I have used divs to hold all of my content. before I used tables.
Anywho.. if any of you could take a lookie and let me know if I am missing something here is my code:

Code: Select all

<body>
<?

// your name
$recipientname = "";

// your email
$recipientemail = "email goes here"

// subject of the email sent to you
$subject = " ";

// thankyou displayed after the user clicks "submit"
$submitmessage = "<div style='position:relative; left:0px; '>Thank You For Your Message, Please allow us 24 hours to respond</div>";
?>


<?

if($submitform) {

	// check required fields
	$dcheck = explode(",",$require);
	while(list($check) = each($dcheck)) {
		if(!$$dcheck[$check]) {
			$error .= "Missing $dcheck[$check]<br>";
		}
	}

	// check email address
	if( !eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*"
   ."@([a-z0-9]+([\.-][a-z0-9]{1,})+)*$",
   $Email, $regs) )
{

   
   $error .= "'$Email' isn't a valid mail address!<BR>";
  

}
elseif( gethostbyname($regs[2]) == $regs[2] )
{
 $error .= "Error: Can't find the host '$regs[2]'!<br>";
}

		// display errors
		if($error) {
?>

<b>Error</b><br>
<? echo $error; ?><br>
<a href="index.php?c=contact" onClick="history.go(-1)">try again</a><BR><BR>
<?
		}else{
		

		// format message
		$message = "Response for $recipientname:
		Name:
		$Name
		
";

		// send mail and print success message
		mail("$recipientemail","$subject","$message","From: $Name");


		echo "$submitmessage";
		}
}
if(!$submitform) {
?>
<form name="contactform" action="contact_page.php" method="post">
<input type="hidden" name="require" value="Name,Email">
<div style=" width:520px; height:648px; z-index:9;">
<div style=" position:relative; left: 16px;"><img src="images/FormBackGround.jpg" border="0"></div>
<div style="position:absolute; top: 83px; left: 108px;"><img src="images/brokerData.jpg"></div>
<div style="position:absolute; width: 200px; top: 115px; left: 110px;">Broker Name:<br>
  <input name="Name" size="30"></div>
<div style="position:absolute; width: 200px; top: 158px; left: 110px;">Title / Owner:<br>
  <input name="Title" size="30"></div>
<div style="position:absolute; width: 200px; top: 201px; left: 110px;">Company Name:<br>
  <input name="Company" size="30"></div>
<div style="position:absolute; width: 200px; top: 244px; left: 110px;">Mailing Address:<br>
  <input name="Mailing_Address" size="30"></div>
<div style="position:absolute; width: 200px; left: 345px; top: 116px;">Tel:<br>
  <input name="Telephone" size="30"></div>
<div style="position:absolute; width: 200px; left: 345px; top: 158px;">Fax:<br>
  <input name="Fax" size="30"></div>
<div style="position:absolute; width: 200px; left: 345px; top: 201px;">Email:<br>
  <input name="Email" size="30"></div>
<div style="position:absolute; top: 297px; left: 110px;">Check boxes, if more than one if it applies</div>
<div style="position:absolute; top: 328px; width: 253px; left: 110px;">Licensed Mortgage Broker&nbsp;&nbsp;&nbsp;Y
  <input name="Licensed_Mortgage_Broker_Y" type="checkbox" value="">&nbsp;N<input name="Licensed_Mortgage_Broker_N" type="checkbox" value=""></div>
<div style="position:absolute; top: 359px; width: 253px; left: 110px;">Licensed Real Estate Agent&nbsp;&nbsp;&nbsp;Y
  <input name="Licensed_Real_Estate_Agent_Y" type="checkbox" value="">&nbsp;N<input name="Licensed_Real_Estate_Agent_N" type="checkbox" value=""></div>
<div style="position:absolute; top: 390px; width: 265px; left: 110px;">Licensed Real Estate Broker&nbsp;&nbsp;&nbsp;Y
  <input name="Licensed_Real_Estate_Broker_Y" type="checkbox" value="">&nbsp;N<input name="Licensed_Real_Estate_Broker_N" type="checkbox" value=""></div>
<div style="position:absolute; top: 421px; width: 254px; left: 110px;">
  <input name="Accountant" type="checkbox" value="">&nbsp;Accountant</div>
<div style="position:absolute; top: 452px; width: 254px; left: 110px;">
  <input name="Lawyer" type="checkbox" value="">&nbsp;Lawyer</div>
<div style="position:absolute; top: 481px; width: 254px; left: 110px;">
  <input name="Consultant" type="checkbox" value="">&nbsp;Consultant</div>
<div style="position:absolute; top: 512px; width: 254px; left: 110px;">
  <input name="Business_Broker" type="checkbox" value="">&nbsp;Business Broker</div>
<div style="position:absolute; top: 543px; width: 254px; left: 110px;">Other relevant licenses / Certifications?<br>
  <input name="Other_Licenses" type="text" size="30"></div>
<div style="position:absolute; top: 596px; width: 412px; left: 110px;">How would you like to receive the referral commission agreement?</div>
<div style="position:absolute; top: 617px; width: 254px; left: 110px;">Fax<input name="Prefered_Fax" type="checkbox" value="">Email<input name="Prefered_Email" type="checkbox" value="">Mail<input name="Prefered_Mail" type="checkbox" value=""></div>
<div style="position:absolute; z-index:10; left: 82px; top: 654px;">
  <input type="image" id="submit" src="images/Send.jpg" value="Submit" name="submitform"></div>

</div>
<? } 
?>
</form>
</body>
Last edited by Benjamin on Sun Apr 25, 2010 12:19 pm, edited 1 time in total.
Reason: Added [syntax=php] tags.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Hello Everyone :)

Post by requinix »

So what does "can't get it to send" mean? Error messages? Blank page? Seems to work except you don't get the email?
Skrilla
Forum Newbie
Posts: 9
Joined: Sun Apr 25, 2010 11:26 am

Re: Hello Everyone :)

Post by Skrilla »

yeah it doesnt load my ty message and send the email.. no errors or anything.. I am going to take another look as soon as I get my kids to bed.
Skrilla
Forum Newbie
Posts: 9
Joined: Sun Apr 25, 2010 11:26 am

Re: Hello Everyone :)

Post by Skrilla »

Seems it has something to do with my send button.. It works fine with the default send btn.. but if I try to add my own image as the buton it will not work.
Could it be because I am using absolute divs? everytime I have used this same script in the past I have had no problems with using my own image for the send button. And I have always used tables in the past..
Skrilla
Forum Newbie
Posts: 9
Joined: Sun Apr 25, 2010 11:26 am

Re: Hello Everyone :)

Post by Skrilla »

Mods can delete this thread now :)
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: Hello Everyone :)

Post by social_experiment »

Skrilla wrote:Could it be because I am using absolute divs? everytime I have used this same script in the past I have had no problems with using my own image for the send button. And I have always used tables in the past..
No it cannot. You have probably solved the problem judging from the last post but 'Absolute' is used with positioning which is styling (CSS) and has 0 effect on the php code.
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
phu
Forum Commoner
Posts: 61
Joined: Tue Mar 30, 2010 6:18 pm

Re: Hello Everyone :)

Post by phu »

Skrilla wrote:Mods can delete this thread now :)
It'd be a lot more helpful for anyone who happened to have the same issue if you gave a brief description of what the problem ended up being and how you solved it.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Hello Everyone :)

Post by Benjamin »

Forum Rules 1 1.1 2 wrote: Use descriptive subjects when you start a new thread. Vague titles such as "Help!", "Why?" are misleading and keep you from receiving an answer to your question.
If you are new to the forums, please be sure to read:
  1. Forum Rules
  2. General Posting Guidelines
  3. Posting Code in the Forums
Skrilla
Forum Newbie
Posts: 9
Joined: Sun Apr 25, 2010 11:26 am

Re: Hello Everyone :)

Post by Skrilla »

Hey guys, sorry about that.
I was using <input> tags with type set to image for my button:

Code: Select all

<input type="image" id="submit" value="Submit" src="images/Send.jpg" name="submitform">
for some reason it would not send the email using it that way.

To fix the problem I put the image in a button tag:

Code: Select all

<button type="submit" name="submitform" value="Submit" style="border: 0; background: transparent; cursor: pointer;"> 
    <img src="images/Send.jpg"  /> 
</button>

And it works fine now.


As far as the checkboxes I simply called the names of the checkboxes:

Code: Select all

$message = "Response for $recipientname:

			Brokers Name: $Name
			Title / Owner: $Title
			Email: $Email
			Company Name: $Company
			Mailing Address: $Mailing_Address
			Telephone: $Telephone
			Fax: $Fax
			
			Licensed Mortgage Broker: $Licensed_Mortgage_Broker_Y $Licensed_Mortgage_Broker_N
			Licensed Real Estate Agent: $Licensed_Real_Estate_Agent_Y $Licensed_Real_Estate_Agent_N
			Licensed Real Estate Broker: $Licensed_Real_Estate_Broker_Y $Licensed_Real_Estate_Broker_N
			
			Accountant? $Accountant
			Business Broker? $Business_Broker
			Lawyer? $Lawyer
			Consultant? $Consultant 
			
			Any other licenses or Certs: 
			$Other_Licenses
			
			How would you like to receive the referral commission agreement? $Prefered_Fax $Prefered_Email $Prefered_Mail
			
			";
Not exactly the cleanest way to do it.. but it works.
Post Reply