Jump to content


contact form help - still need help


21 replies to this topic

#1 zoom4267

    Young Padawan

  • Members
  • Pip
  • 191 posts
  • Gender:Female
  • Location:USA

Posted 04 September 2007 - 02:41 PM

im trying to get a working contact form.

i have tried the php contact form from this tutorial but it didnt work

http://www.dreamweav...er-php-form.php
site

i did a basic one in DW but after you hit submit it openes up another email form to fill out.

how do i get one to work properly

thanks

Lisa

Edited by zoom4267, 04 September 2007 - 03:45 PM.


#2 zoom4267

    Young Padawan

  • Members
  • Pip
  • 191 posts
  • Gender:Female
  • Location:USA

Posted 07 September 2007 - 07:15 AM

has any one used the FormMail.pl from mats script archive?

i am having problems getting that to work too

i know this should be easy, but i cant seem to get any form to work properly

thanks

#3 Braunson

    Young Padawan

  • Members
  • Pip
  • 237 posts
  • Gender:Male
  • Location:Ontario, Canada

Posted 07 September 2007 - 07:59 AM

Nobody is anwsering you simple because, you can search P2L for 'contact form' and you'll come up with monsterous results.

#4 zoom4267

    Young Padawan

  • Members
  • Pip
  • 191 posts
  • Gender:Female
  • Location:USA

Posted 07 September 2007 - 08:08 AM

okay, sorry, let me search again. i did a search but didnt come up with much, im sure its common.

thanks

#5 .CJ

    Young Padawan

  • Members
  • Pip
  • 114 posts
  • Gender:Male
  • Location:Leeds, UK

Posted 07 September 2007 - 01:42 PM

<?php
if(isset($_POST['submit'])) {
  echo('Hello, '.$_POST['name'].'');
  // Actually anything can go in here
}
else {
?>
<form action="" method="post">
<input type="text" name="name" /><br />
<input type="submit" name="submit" value="Submit" />
</form>
<?php
}
?>
This is a real simple way to do it, basically it first checks if the form has been submitted using isset() and is so... it displays your content; I used a simple message using the value of the name text input. If the form isn't submitted, it'll display the form. Whatever you call your input field is how you call them using the $_POST variable.

Hope that helps.

#6 zoom4267

    Young Padawan

  • Members
  • Pip
  • 191 posts
  • Gender:Female
  • Location:USA

Posted 07 September 2007 - 02:31 PM

thanks alot. but when i hit submit another email pop up comes up, for example, if i am in IE, the outlook pop up comes up and has the email for that, then you would have to fill that out. thats not what i was aiming for. just fill the form out on the site an hit submit and off it goes. is there something im not doing>?

#7 .CJ

    Young Padawan

  • Members
  • Pip
  • 114 posts
  • Gender:Male
  • Location:Leeds, UK

Posted 08 September 2007 - 02:49 PM

That's odd :\ never had that problem before. The code is in a .PHP page right? Only thing I can imagine is that your e-mail settings are set up oddly.

Will have to ask someone else about this, as I'm baffled.

#8 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 08 September 2007 - 03:16 PM

You probably changed the action to a mailto action. Leave the action attribute blank or put it as:
<form method="post" action="<? echo $_SERVER['REQUEST_URI']; ?>">


#9 zoom4267

    Young Padawan

  • Members
  • Pip
  • 191 posts
  • Gender:Female
  • Location:USA

Posted 08 September 2007 - 03:41 PM

View Postrc69, on Sep 8 2007, 04:16 PM, said:

You probably changed the action to a mailto action. Leave the action attribute blank or put it as:
<form method="post" action="<? echo $_SERVER['REQUEST_URI']; ?>">


i didnt change the action to anything but what i did realize is i didnt rename my contact to .php, i had left it .html

#10 zoom4267

    Young Padawan

  • Members
  • Pip
  • 191 posts
  • Gender:Female
  • Location:USA

Posted 08 September 2007 - 06:36 PM

okay. stupid question,,, but if i have to leave the mailto action then how do i set where the mail goes

thanks

#11 Demonslay

    P2L Jedi

  • Members
  • PipPipPip
  • 970 posts
  • Gender:Male
  • Location:A strange world where water falls out of the sky... for no reason.
  • Interests:Graphic Design, Coding, Splinter Cell, Cats

Posted 08 September 2007 - 07:05 PM

That's the point of using PHP to send the mail using the mail() function...
The mailto protocol will simply tell the browser to open up an email client if it can, and force the user to type all the stuff in the email client, and send it themselves. Using a server-side script, you can have the server do the work and the user knowns none the better.

Plus it gives you more control as to the headers, spam control, even complex stuff like attachments.

#12 zoom4267

    Young Padawan

  • Members
  • Pip
  • 191 posts
  • Gender:Female
  • Location:USA

Posted 08 September 2007 - 07:07 PM

thanks

i put the code in that CJ posted but i didnt receive the mail. how do i find the problem

The mailto protocol will simply tell the browser to open up an email client if it can, and force the user to type all the stuff in the email client

does this mean another email window will open for the visitor to fill out? that is what i want to avoid

the site is www.mktstrategies.com


thanks

Edited by zoom4267, 08 September 2007 - 07:09 PM.


#13 Demonslay

    P2L Jedi

  • Members
  • PipPipPip
  • 970 posts
  • Gender:Male
  • Location:A strange world where water falls out of the sky... for no reason.
  • Interests:Graphic Design, Coding, Splinter Cell, Cats

Posted 08 September 2007 - 08:02 PM

You have to actually use the mail() function (<-- notice the link).
Read the comments for basically anything you'd need.

If after everything, you can't get the function to work, then it is most likely your host has disabled the use of the function, since some hosts do because of abuse. If this is a suspicion, you can check with them, or look at the results of phpinfo() under the php.ini directives.

#14 zoom4267

    Young Padawan

  • Members
  • Pip
  • 191 posts
  • Gender:Female
  • Location:USA

Posted 10 September 2007 - 06:13 AM

View PostDemonslay, on Sep 8 2007, 09:02 PM, said:

You have to actually use the mail() function (<-- notice the link).
Read the comments for basically anything you'd need.

If after everything, you can't get the function to work, then it is most likely your host has disabled the use of the function, since some hosts do because of abuse. If this is a suspicion, you can check with them, or look at the results of phpinfo() under the php.ini directives.

<?php
if(isset($_POST['submit'])) {
echo('Hello, '.$_POST['name'].'');
//
}
else {
?>
<form method="post" action="<? echo $_SERVER['REQUEST_URI']; ?>">

<table width="300" border="0" cellspacing="0" cellpadding="0">
(rest of form)
</form>

<?php
}
?>

this is the code i have, i looked at the php page, but im a dunce with php, you can hit me over the head if you want.

did i miss something? or is it my server

thank you very much

#15 Demonslay

    P2L Jedi

  • Members
  • PipPipPip
  • 970 posts
  • Gender:Male
  • Location:A strange world where water falls out of the sky... for no reason.
  • Interests:Graphic Design, Coding, Splinter Cell, Cats

Posted 11 September 2007 - 05:52 PM

You have to actually tell the server what to do. It won't just magically assume you are mailing the contents of the form...

Take the link, and goto the documentation for mail(), and you'll be able to find plenty of information on how to use it. If you are still confused, there are plenty of tutorials if you search for it in the PHP section of P2L here.

#16 zoom4267

    Young Padawan

  • Members
  • Pip
  • 191 posts
  • Gender:Female
  • Location:USA

Posted 14 September 2007 - 07:26 PM

here is the code i have for the mail. is there something in here that i may have wrong because i dont receive mail from my website.

thanks


<?PHP
if($_POST['submit'])
{

// submit being the name of the submit button =]
// some checks to make sure the content is there


// this would be the part it sends from

$contact = $_POST['contact'];
$subject = "Contact form from: " . $contact;
$header = "FROM: " . $_POST[email];
mail("market@mktstrategies.com", $subject, $_POST[message],$header);
echo '
<script type="text/javascript">
window.location="Contact Us.html";
</script>';

}
?>


<form id="form1" name="form1" method="post" action="">

#17 .CJ

    Young Padawan

  • Members
  • Pip
  • 114 posts
  • Gender:Male
  • Location:Leeds, UK

Posted 14 September 2007 - 08:43 PM

<?php
if(isset($_POST['submit'])) {
	$contact = $_POST['contact'];
	$subject = $_POST['subject'];
	$header = "From:".$_POST['email'];
	// Check if mail sent
	if(mail($contact, $subject, $_POST['message'], $header)) {
		echo('Mail sent');
	}
	else {
		echo('Mail not sent');
	}
}
?>
Tell us if it says 'Mail sent' or 'Mail not sent' and we'll work from that

#18 zoom4267

    Young Padawan

  • Members
  • Pip
  • 191 posts
  • Gender:Female
  • Location:USA

Posted 15 September 2007 - 05:23 AM

thanks


it didnt say anything, i hit submit and the page refreshed

i had called the web host and they checked and everything on thier end seems to be working.

Edited by zoom4267, 15 September 2007 - 05:32 AM.


#19 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 15 September 2007 - 12:36 PM

Could you post all of the code you have, form and all? Also, make sure you have a .php file, not a .html file.

Edited by rc69, 15 September 2007 - 12:37 PM.


#20 zoom4267

    Young Padawan

  • Members
  • Pip
  • 191 posts
  • Gender:Female
  • Location:USA

Posted 15 September 2007 - 01:58 PM

View Postrc69, on Sep 15 2007, 01:36 PM, said:

Could you post all of the code you have, form and all? Also, make sure you have a .php file, not a .html file.

the page is "contact.php"

thanks so much


<?php
if(isset($_POST['submit'])) {
$contact = $_POST['contact'];
$subject = $_POST['subject'];
$header = "From:".$_POST['email'];
mail("market@mktstrategies.com", $subject, $_POST[message],$header);

// Check if mail sent
if(mail($contact, $subject, $_POST['message'], $header)) {
echo('Mail sent');
}
else {
echo('Mail not sent');
}
}
?>


<form id="form1" name="form1" method="post" action="">
<table width="518" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="175">&nbsp;</td>
<td width="122" height="32">Business Name </td>
<td width="221"><input name="business name" type="text" id="business name" /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td height="32">Street</td>
<td><input name="street" type="text" id="street" /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td height="32">Town</td>
<td><input name="town" type="text" id="town" /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td height="32">State</td>
<td><input name="state" type="text" id="state" /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td height="32">Zip</td>
<td><input name="zip" type="text" id="zip" /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td height="32">Contact Name </td>
<td><input name="contact name" type="text" id="contact name" /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td height="32">Position</td>
<td><input name="position" type="text" id="position" /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td height="32">Phone # </td>
<td><input name="phone" type="text" id="phone" /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td height="32">Email</td>
<td><input name="email" type="text" id="email" /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>Message</td>
<td><textarea name="message" rows="5" id="message"></textarea></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><input type="submit" name="Submit" value="Submit" /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
</form>





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users