Board index   FAQ   Search  
Register  Login
Board index PHP PHP Scripts

PHP form not working, help needed!!

Links for php scripts

Moderators: macek, egami, gesf

PHP form not working, help needed!!

Postby mortoni » Tue May 29, 2012 6:03 am

Hi,

I have been trying to get this form to work and am unable to get it right due to the fact that I mainly work in html....

Here is the PHP in the top of the page:

<?php

import_request_variables("gP", "_");

/** require_once("sendmail.php"); */

if ($_Submit == "Submit") {

$msgTmp .= "Name : $_name\r\n";
$msgTmp .= "Address 1 : $_address1\r\n";
$msgTmp .= "Address 2 : $_address2\r\n";
$msgTmp .= "County : $_county\r\n";
$msgTmp .= "Postcode : $_textfield\r\n";
$msgTmp .= "Email : $_textfield2\r\n";
$msgTmp .= "Phone : $_textfield3\r\n";

$msgTmp .= "What is your enquiry ? : $_textarea\r\n\r\n";

if ($_marketing_consultancy == 1) {
$msgOtherTmp .= "";
}
if ($_designgraphics == 1) {
$msgOtherTmp .= "";
}
if ($_companyliterature == 1) {
$msgOtherTmp .= "";
}
if ($_webmultimedia == 1) {
$msgOtherTmp .= "";
}
if ($_exhibition == 1) {
$msgOtherTmp .= "";
}
if ($_other == 1) {
$msgOtherTmp .= "Other type of enquiry\r\n";
}



else {
$msgOtherTmp = "\r\n" . $msgOtherTmp;
}

$message = $msgTmp . $msgOtherTmp;

if ((isset($message)) && ($message != "")) {
// smtpmail("stones.wood@zen.co.uk", "stones.wood@zen.co.uk", "Website Enquiry", $message, "From: $_name<"."$_emailaddress".">\r\n"."Reply-To: $_emailaddress\r\n"."Return-Path: $_emailaddress\r\n"."X-Mailer: PHP/".phpversion());
mail ("stones.wood@zen.co.uk", "Website Enquiry", $message, "From: $_name<"."$_emailaddress".">\r\n"."Reply-To: $_emailaddress\r\n"."Return-Path: $_emailaddress\r\n"."X-Mailer: PHP/".phpversion());

$msg = "Your details have been emailed to:stones.wood@zen.co.uk<br /><pre>$message</pre>";

/* Change this to where you want the script to go once it has emailed the details */
header("Location:http://www.stoneswoodretirement.co.uk/thanks.html");
} else {
/* If you get here, something bad has happened ?? */
$msg = "<b>Error!!</b><br />\n";

$msg .= "<br />State \"Error Response Form\" in subject/topic<br />\n";
}
}

?>

And here is the html form:

<table width="420" border="1" bordercolor="#FFFFFF" align="center" cellpadding="0" cellspacing="0" bgcolor="e4e1e1">
<tr><form>
<td width="420" valign="top">
<table width="365" border="0" align="center" cellpadding="6" cellspacing="0">
<tr>
<td width="76"><div align="right" class="bodytext">Name</div></td>
<td width="2">&nbsp;</td>
<td width="251"><div align="left">
<input name="name" type="text" id="name" size="30" maxlength="100">
</div></td>
</tr>
<tr>
<td><div align="right" class="bodytext">Address 1</div></td>
<td>&nbsp;</td>
<td><div align="left">
<input name="address1" type="text" id="address1" size="30" maxlength="100">
</div></td>
</tr>
<tr>
<td><div align="right" class="bodytext">Address 2</div></td>
<td>&nbsp;</td>
<td><div align="left">
<input name="address2" type="text" id="address2" size="30" maxlength="100">
</div></td>
</tr>
<tr>
<td><div align="right" class="bodytext">County</div></td>
<td>&nbsp;</td>
<td><div align="left">
<input name="county" type="text" id="county" size="20" maxlength="30">
</div></td>
</tr>
<tr>
<td><div align="right" class="bodytext">Postcode</div></td>
<td>&nbsp;</td>
<td><div align="left">
<input name="textfield" type="text" size="10" maxlength="10">
</div></td>
</tr>
<tr>
<td><div align="right" class="bodytext">Email</div></td>
<td>&nbsp;</td>
<td><div align="left">
<input name="textfield2" type="text" size="30" maxlength="100">
</div></td>
</tr>
<tr>
<td><div align="right" class="bodytext">Phone</div></td>
<td>&nbsp;</td>
<td><div align="left">
<input name="textfield3" type="text" size="30" maxlength="100">
</div></td>
</tr>
<tr>
<td colspan="3"></td>
</tr>

<tr>
<td colspan="3"><div align="center" class="bodytext">What
is your enquiry?</div></td>
</tr>
<tr>
<td colspan="3"><div align="center">
<textarea name="textarea" cols="30" rows="6"></textarea>
</div></td>
</tr>
</table>
<div align="center">
<input type="submit" name="Submit" value="Submit"onClick="MM_popupMsg('Thank you for your submission.')" >


It did used to work before PHP was updated but now it has an error everytime the page opens.

I would be eternally grateful if someone knows how to make it work again.

many thanks guys.
mortoni
New php-forum User
New php-forum User
 
Posts: 4
Joined: Tue May 29, 2012 5:47 am

Re: PHP form not working, help needed!!

Postby freshnet » Tue May 29, 2012 2:35 pm

what's the error you get?
User avatar
freshnet
php-forum Active User
php-forum Active User
 
Posts: 274
Joined: Tue Feb 22, 2011 8:19 am
Location: Canada

Re: PHP form not working, help needed!!

Postby mortoni » Wed May 30, 2012 12:28 am

Hi, thanks for asking.

This is the error that appears now:

Notice: Undefined variable: _Submit in E:\Domains\s\stoneswoodretirement.co.uk\user\htdocs\contact.php on line 7


Any help would be appreciated.
mortoni
New php-forum User
New php-forum User
 
Posts: 4
Joined: Tue May 29, 2012 5:47 am

Re: PHP form not working, help needed!!

Postby Nullsig » Wed May 30, 2012 7:30 am

Can't use the _ before a variable. $_ in PHP is used to describe SuperGlobals.
User avatar
Nullsig
php-forum Fan User
php-forum Fan User
 
Posts: 981
Joined: Thu Feb 17, 2011 6:52 am
Location: Racine, WI

Re: PHP form not working, help needed!!

Postby mortoni » Wed May 30, 2012 1:27 pm

Thanks Nullsig,
So what do I need to do?
I'm a bit of a newbie here.

From this:

if ($_Submit == "Submit") {

Do I need to loose the underscore like this?

if (Submit == "Submit") {

I am really appreciating all your help guys.
mortoni
New php-forum User
New php-forum User
 
Posts: 4
Joined: Tue May 29, 2012 5:47 am

Re: PHP form not working, help needed!!

Postby Nullsig » Thu May 31, 2012 4:54 am

$submit == "Submit"
User avatar
Nullsig
php-forum Fan User
php-forum Fan User
 
Posts: 981
Joined: Thu Feb 17, 2011 6:52 am
Location: Racine, WI

Re: PHP form not working, help needed!!

Postby mortoni » Thu May 31, 2012 10:05 am

I've just tried this and it is still asking me to 'define the variable' .....anyone??? :(
mortoni
New php-forum User
New php-forum User
 
Posts: 4
Joined: Tue May 29, 2012 5:47 am

Re: PHP form not working, help needed!!

Postby Nullsig » Thu May 31, 2012 11:01 am

Sorry I should have fully read...

Code: Select all
if($_POST['Submit'] == "Submit')
User avatar
Nullsig
php-forum Fan User
php-forum Fan User
 
Posts: 981
Joined: Thu Feb 17, 2011 6:52 am
Location: Racine, WI


Return to PHP Scripts

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron