Submit Your Article Webforumz RegistrationAnnouncements Contact Webforumz StaffContact
Home Resources Blogs Meet the Team Contact Register
 

Go Back   WebForumz.com > The Code > PHP

Reply
 
LinkBack Thread Tools
Old December 1st, 2006, 06:09 PM   #1
New Member
 

Join Date: Dec 2006
Location: london
Age: 37
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 enrique is on a distinguished road
Angry can get php to process my form, why?

I'm trying to use the following script to process a form (below) I've been racking my brains over this one and am at breaking point....it just doesn't seem to work can anyone help please?

<?php
// Get submitted data
$name = $HTTP_POST_VARS['name'];
$company = 'From: '.$HTTP_POST_VARS['company'];
$phone = $HTTP_POST_VARS['phone'];
$message = $HTTP_POST_VARS['message'];

// Put data into readable format
$to = 'enrique@hotmail.co.uk';
$body = 'Name: '.$name.'\n'
.'Company: '.$company.'\n'
.'email: '.$email.'\n'
.'Message: \n \n'.$message;

// Send email
mail($to, $body, $email);
header( "Location: http://www.webhotdesign.co.uk/whd/pages/thanks.htm" );
?>



<form name="form" id="form" method="post" action="form.php">
<!--DWLayoutTable-->
<tr>
<td width="32" rowspan="9" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
<td height="66" colspan="2" valign="middle"><!--DWLayoutEmptyCell-->&nbsp;</td>
<td width="1"></td>
<td width="26">&nbsp;</td>
<td width="334">&nbsp;</td>
<td width="106">&nbsp;</td>
</tr>
<tr>
<td width="69" height="21" valign="top">name<br> </td>
<td colspan="2" rowspan="8" valign="top"> <p>
<input name="name" type="text" id="name" size="15" maxlength="20" />
<br>
<br>
<input name="phone" type="text" id="phone" size="15" maxlength="20" />
<br>
<br>
<input name="email" type="text" id="email" size="15" maxlength="25" />
<br>
<br>
<textarea name="message" cols="15" rows="4" wrap="VIRTUAL"></textarea>
</p>
<p>
<input class=aceButton type="submit" value="submit">
</td>
<td>&nbsp;</td>
<td rowspan="4" valign="top"> For all initial enquiries please use the form
<br><br> Tel: 07782 216 212 <br>
Email <a href="mailto:enrique@webhotdesign.co.uk">enrique@w ebhotdesign.co.uk</a>
</td>
<td>&nbsp;</td>
</tr>
<tr>
<td height="20" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td height="21" valign="top">phone</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td rowspan="2" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
<td height="14"></td>
<td></td>
</tr>
<tr>
<td height="6"></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="21" valign="top">email</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="20" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="164" valign="top"><br>
message</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="1"></td>
<td></td>
<td width="182"></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr></form>
</table>
enrique is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old December 1st, 2006, 07:26 PM   #2
Highly Reputable Member
 
masonbarge's Avatar
 

Join Date: Jan 2006
Location: Atlanta GA
Posts: 649
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 masonbarge will become famous soon enough
Re: can get php to process my form, why?

Code:
 $company = 'From:  '.$HTTP_POST_VARS['company'];
I'd rewrite this. I'm not on firm ground here, but echo syntax doesn't work for variable assignments sometimes. I'd just write $company = $HTTP_POST_VARS['company']; and concat $company as needed.

Probably not it, wish I could be more help.
masonbarge is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old December 2nd, 2006, 07:26 AM   #3
New Member
 

Join Date: Oct 2006
Location: Uxbridge, West London
Age: 27
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 gustava32 is on a distinguished road
Re: can get php to process my form, why?

Is it because you have not told it when it needs to run the PHP that processes it?So it just runs it straight away. I think you need to change it too something like this.

Code:
 <?php
if($HTTP_POST_VARS[submit]) //This means it will not process this section until 
{                                             //the submit button is pressed.
//  Get submitted data
$name $HTTP_POST_VARS['name'];
$company 'From:  '.$HTTP_POST_VARS['company'];
$phone $HTTP_POST_VARS['phone'];
$message  $HTTP_POST_VARS['message']; 

// Put data into readable format
$to =  'enrique@hotmail.co.uk';
$body 'Name: '.$name.'\n'
.'Company:  '.$company.'\n'
.'email: '.$email.'\n'
.'Message: \n \n'.$message;  

// Send email
mail($to$body$email);
header"Location:  http://www.webhotdesign.co.uk/whd/pages/thanks.htm"  );
}
?>
Unless I am getting the wrong end of the stick.

Hope this helps.
Gareth
gustava32 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old December 2nd, 2006, 02:42 PM   #4
New Member
 

Join Date: Dec 2006
Location: london
Age: 37
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 enrique is on a distinguished road
Re: can get php to process my form, why?

cheers guys for the suggestions, but i've taken everything on board and tried it but it still doesn't work - the header part works which is basically
the thank you page, but that's it....

any other suggestions?
enrique is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old December 2nd, 2006, 03:56 PM   #5
New Member
 

Join Date: Oct 2006
Location: Uxbridge, West London
Age: 27
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 gustava32 is on a distinguished road
Re: can get php to process my form, why?

What exactly is it doing?

What is is supposed to be doing?
gustava32 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old December 2nd, 2006, 04:23 PM   #6
New Member
 

Join Date: Dec 2006
Location: london
Age: 37
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 enrique is on a distinguished road
Re: can get php to process my form, why?

It's supposed to get the info of the form and send it over to my hotmail account but it doesn't do it.
the header (the thankyou page) appears and that's it......
enrique is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old December 2nd, 2006, 05:25 PM   #7
New Member
 

Join Date: Oct 2006
Location: Uxbridge, West London
Age: 27
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 gustava32 is on a distinguished road
Re: can get php to process my form, why?

How about changing the body bit to this and see if that works:
Code:
$body "Name: $name\nCompany: $company\nemail: $email\nMessage: \n \n$message"
See if that helps!
gustava32 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old December 4th, 2006, 12:17 PM   #8
New Member
 

Join Date: Dec 2006
Location: london
Age: 37
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 enrique is on a distinguished road
Re: can get php to process my form, why?

hi there,

I tried that but still nothing - Is there anything else I can try or maybe start from scratch...

Once again the setup is that I have :-

the formpage
the php page
and the thank you page (header)

three name fields: name, company and phone as well as a textarea (message)

can you suggest something ?? getting desperate now. Didn't think that it would be so troublesome..
enrique is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old December 4th, 2006, 04:59 PM   #9
Highly Reputable Member
 
masonbarge's Avatar
 

Join Date: Jan 2006
Location: Atlanta GA
Posts: 649
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 masonbarge will become famous soon enough
Re: can get php to process my form, why?

1)What version of php are you using?

2) What mail program are you using, i.e. check php_ini for sendmail. If you're using some other program you need to make adjustments.

3) Try taking the newline markers out of the $body, that will screw it up sometimes. Actually do that first as it is the easiest thing to try.

Actually, don't you need a subject in the second parameter spot? No great expert, just trying to help you think of something.

Last edited by masonbarge; December 4th, 2006 at 05:02 PM..
masonbarge is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old December 5th, 2006, 12:07 PM   #10
New Member
 

Join Date: Dec 2006
Location: london
Age: 37
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 enrique is on a distinguished road
Re: can get php to process my form, why?

hi,

Thanks for the tips I have tried them but still nothing.

The server which is hosting my site supports php4 if that helps...
with regards to what i'm using locally on my machine well nothing.
I just upload it straight to server and test it there...

The header the thank you page appears but that's it.
enrique is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old December 6th, 2006, 06:16 AM   #11
New Member
 

Join Date: Oct 2006
Location: Uxbridge, West London
Age: 27
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 gustava32 is on a distinguished road
Re: can get php to process my form, why?

If only the header to the thankyou page displays then there is something wrong with your PHP in the thankyou page.

Post that here as well and I will see if can spot that problem.
gustava32 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old December 6th, 2006, 06:40 AM   #12
New Member
 

Join Date: Oct 2006
Location: Uxbridge, West London
Age: 27
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 gustava32 is on a distinguished road
Re: can get php to process my form, why?

Also i have just been looking through your code again and I see that you are using things that dont even exist which might not help.

For example you are trying to get data from
Code:
<?php $company $HTTP_POST_VARS['company'] ;?>
when you dont even have a company field. I suggest you rewrite the page from scratch and also do it manually as the dreamweaver template seems pretty messed up too me!
gustava32 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old December 6th, 2006, 06:49 AM   #13
New Member
 

Join Date: Oct 2006
Location: Uxbridge, West London
Age: 27
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 gustava32 is on a distinguished road
Re: can get php to process my form, why?

I have just tweaked it a little bit more and managed to get it too work for me!
Here is the code:

Code:
<!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=iso-8859-1" />
<title>Test Page</title>
</head>

<body>
<?php
// Get submitted data
if ($HTTP_POST_VARS['submit'])
{
$name $HTTP_POST_VARS['name'];
$company 'From: '.$HTTP_POST_VARS['company'];
$phone $HTTP_POST_VARS['phone'];
$message $HTTP_POST_VARS['message'];
$email $HTTP_POST_VARS['email'];

// Put data into readable format
$to 'enrique@hotmail.co.uk';
$subject 'test email';
$body "Name: $name.\n Company: $company\n email: $email\n Message: \n \n$message";

// Send email
if(mail($to$subject$body$company ))
{

//header( "Location: http://www.webhotdesign.co.uk/whd/pages/thanks.htm" );
echo "Mail Sent";
}
else
{
    echo 
"There was an error sending your email.";
}
}
?>



<form name="form" id="form" method="post" action="form.php">
<!--DWLayoutTable-->
<tr>
<td width="32" rowspan="9" valign="top"><br> </td>
</tr>
<tr>Name</tr>
<tr><td width="69" height="21" valign="top">&nbsp;</td>
<td colspan="2" rowspan="8" valign="top"> <p>
<input name="name" type="text" id="name" size="15" maxlength="20" />
<br>
<br>
<input name="phone" type="text" id="phone" size="15" maxlength="20" />
<br>
<br>
<input name="company" type="text" id="company" size="25" maxlength="25" />
<br>
<br>
<input name="email" type="text" id="email" size="15" maxlength="25" />
<br>
<br>
<textarea name="message" cols="15" rows="4" wrap="VIRTUAL"></textarea>
</p>
<p>
<input class=aceButton type="submit" value="submit" name="submit">
</td>
<td>&nbsp;</td>
<td rowspan="4" valign="top"> For all initial enquiries please use the form
<br><br> Tel: 07782 216 212 <br>
Email <a href="mailto:enrique@webhotdesign.co.uk">enrique@w ebhotdesign.co.uk</a>
</td>
<td>&nbsp;</td>
</tr>
<tr>
<td height="20" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td height="21" valign="top">phone</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td rowspan="2" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
<td height="14"></td>
<td></td>
</tr>
<tr>
<td height="6"></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="21" valign="top">email</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="20" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="164" valign="top"><br>
message</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="1"></td>
<td></td>
<td width="182"></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr></form>
</table>
</body>
</html>
I would still suggest completely re-organising it though!
gustava32 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old December 6th, 2006, 09:48 AM   #14
Highly Reputable Member
 
masonbarge's Avatar
 

Join Date: Jan 2006
Location: Atlanta GA
Posts: 649
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 masonbarge will become famous soon enough
Re: can get php to process my form, why?

Having the mandatory 'subject' parameter probably helps
masonbarge is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old December 6th, 2006, 10:36 AM   #15
Elite Veteran
 

Join Date: Dec 2005
Location: On Internet
Posts: 4,850
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 JacobHaug is a jewel in the rough JacobHaug is a jewel in the rough JacobHaug is a jewel in the rough JacobHaug is a jewel in the rough
Re: can get php to process my form, why?

Does that work?
JacobHaug is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old December 6th, 2006, 03:52 PM   #16
New Member
 

Join Date: Dec 2006
Location: london
Age: 37
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 enrique is on a distinguished road
Re: can get php to process my form, why?

hi gustava, for your last comment...


This time I tried intergrating the code within the contact page itself, as you had laid it out and changed the form action to PHP_$SELF - I guess thats the right thing to do but still no joy..

Any other suggestions ?
enrique is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Bookmarks

Tags
php , forms


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Review of WOTM Process Jack Franklin Entry, Nominations and Voting 0 February 15th, 2008 03:11 PM
ASP Form - email won't process tinggg Classic ASP 7 November 28th, 2007 06:37 AM
Where to start in the development process jeremyc PHP 5 October 12th, 2007 03:36 AM
button to kill process kal JavaScript 3 December 13th, 2005 05:33 PM
Form handling Process in ASP? sazhagianambi Classic ASP 4 May 27th, 2004 08:59 AM


Search Engine Optimization by vBSEO 3.2.0 RC8