Jump to content

Problem with Form


poleman

Recommended Posts

Hi there,

 

Am trying to get this form to work but getting puzzled... what is going wrong?

I want it to send the form's contents by email to a specified email address.

It is redirecting via another url as the home url's server does not support php.

<form>
              <form action="http://www.feniaaly.com/contact.php" method="post">
<table border="0" cellpadding="8" cellspacing="8" summary="feedback form">
<tr><td width="100"><span lang="en-gb"><font face="Verdana" size="2">Name:</font></span></td>
<td width="226"><input type="text" name="name" size="25" /></td></tr>
<tr>
  <td><span lang="en-gb"><font face="Verdana" size="2">Email Address:</font></span></td>
  <td><input type="text" name="email" size="25" /></td>
</tr>
<tr>
  <td><span lang="en-gb"><font face="Verdana" size="2">Telephone:</font></span></td><td><input type="text" name="email" size="25" /></td></tr>
<tr>
<td colspan="2">
<span lang="en-gb"><font face="Verdana" size="2">Query:</font></span><br />
<textarea rows="15" cols="45" name="comments"></textarea></td>
</tr>
<tr>
<td align="center" colspan="2">
<input type="submit" value="Send Query" /></td>
</tr>
</table>
</form>

 

Thanks

 

Richard

Link to comment
https://forums.phpfreaks.com/topic/79260-problem-with-form/
Share on other sites

Sure, here you go...

 

<?PHP
######################################################
#                                                    #
#                Forms To Go 3.1.1                   #
#             http://www.bebosoft.com/               #
#                                                    #
######################################################

######################################################
#                                                    #
#                UNREGISTERED VERSION                #
#                                                    #
######################################################



DEFINE('kOptional', True);
DEFINE('kMandatory', False);




error_reporting(E_ERROR | E_WARNING | E_PARSE);
ini_set('track_errors', true);

function DoStripSlashes($FieldValue) 
{ 
if ( get_magic_quotes_gpc() ) { 
  if (is_array($FieldValue) ) { 
   return array_map('DoStripSlashes', $FieldValue); 
  } else { 
   return stripslashes($FieldValue); 
  } 
} else { 
  return $FieldValue; 
} 
}

#----------
# FilterCChars:

function FilterCChars($TheString)
{
return preg_replace('/[\x00-\x1F]/', '', $TheString);
}

#----------
# Validate: Email

function check_email($email, $optional)
{
if ( (strlen($email) == 0) && ($optional === true) ) {
  return true;
} elseif ( eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $email) ) {
  return true;
} else {
  return false;
}
}



if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ClientIP = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ClientIP = $_SERVER['REMOTE_ADDR'];
}

$FTGname = DoStripSlashes( $_REQUEST['Name'] );
$FTGtel = DoStripSlashes( $_REQUEST['Email Address'] );
$FTGemail = DoStripSlashes( $_REQUEST['Telephone'] );
$FTGmessage = DoStripSlashes( $_REQUEST['Query'] );


# Fields Validations

$ValidationFailed = false;

if (!check_email($FTGemail, kMandatory)) {
$ValidationFailed = true;
}


# Include message in error page and dump it to the browser

if ($ValidationFailed === true) {

$ErrorPage = '<html><head><title>Error</title></head><body>';
$ErrorPage .= 'Errors found: <!--VALIDATIONERROR-->';
$ErrorPage .= '</body></html>';

$ErrorPage = str_replace('<!--VALIDATIONERROR-->', $ErrorList, $ErrorPage);

$ErrorPage = str_replace('<!--FIELDVALUE:name-->', $FTGname, $ErrorPage);
$ErrorPage = str_replace('<!--FIELDVALUE:tel-->', $FTGtel, $ErrorPage);
$ErrorPage = str_replace('<!--FIELDVALUE:email-->', $FTGemail, $ErrorPage);
$ErrorPage = str_replace('<!--FIELDVALUE:message-->', $FTGmessage, $ErrorPage);
  

echo $ErrorPage;
exit;

}
# Email to Form Owner

$emailSubject = FilterCChars("Enquiry from ITS Website");

$emailBody = "FAO: ITS"
. "\n"
. "\n"
. "Name : $FTGName\n"
. "Tel : $FTGEmail Address\n"
. "Email : $FTGTelephone\n"
. "Message : $FTGQuery\n"
. "\n"
. "Thanks\n"
. "\n"
. "$FTGName\n"
. "";
$emailTo = "<[email protected]>";
  
$emailFrom = FilterCChars("$FTGName");
  
$emailHeader = "From: $emailFrom\n"
  . "Cc: <[email protected]>" . "\n"
  . "MIME-Version: 1.0\n"
  . "Content-type: text/plain; charset=\"ISO-8859-1\"\n"
  . "Content-transfer-encoding: 8bit\n";
  
mail($emailTo, $emailSubject, $emailBody, $emailHeader);


# Redirect user to success page

header("Location: http://www.itstravel.co.uk/thankyou.html");
exit;
?>

Link to comment
https://forums.phpfreaks.com/topic/79260-problem-with-form/#findComment-401192
Share on other sites

thanks... this is a good site and programme but I'm still having problems. The contact.htm page simply refreshes instead of going to the thankyou page.

 

Here is the url that gets displayed after submitting the form:

http://www.itstravel.co.uk/contact.htm?name=test&email=test&email=test&comments=test

 

here are the two scripts. Hope you can help...

 

HTML - the form is sent to usip.co.uk where the php code is hosted as the its.co.uk server does not support php.

<form>
              <form action="http://www.usip.co.uk/feedback.php" method="post">
<table border="0" cellpadding="8" cellspacing="8" summary="feedback form">
<tr><td><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Name:</font></td><td><input type="text" name="name" size="25" /></td></tr>
<tr>
  <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Email address:</font></td>
  <td><input type="text" name="email" size="25" /></td>
</tr>
<tr>
  <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Telephone:</font></td><td><input type="text" name="email" size="25" /></td></tr>
<tr>
<td colspan="2">
<font size="2" face="Verdana, Arial, Helvetica, sans-serif">Message</font>:<br />
<textarea rows="15" cols="45" name="comments"></textarea></td>
</tr>
<tr>
<td align="center" colspan="2">
<input type="submit" value="Send Query" /><br /></td>
</tr>
</table>
</form>

 

Here is the PHP code:

<?php
/*
    CHFEEDBACK.PHP Feedback Form PHP Script Ver 2.08
    Generated by thesitewizard.com's Feedback Form Wizard.
    Copyright 2000-2007 by Christopher Heng. All rights reserved.
    thesitewizard and thefreecountry are trademarks of Christopher Heng.

    Get the latest version, free, from:
        http://www.thesitewizard.com/wizards/feedbackform.shtml

You can read the Frequently Asked Questions (FAQ) at:
	http://www.thesitewizard.com/wizards/faq.shtml

I can be contacted at:
	http://www.thesitewizard.com/feedback.php
Note that I do not normally respond to questions that have
already been answered in the FAQ, so *please* read the FAQ.

    LICENCE TERMS
    
    1. You may use this script on your website, with or
    without modifications, free of charge.
    
    2. You may NOT distribute or republish this script,
    whether modified or not. The script can only be
    distributed by the author, Christopher Heng.
    
    3. THE SCRIPT AND ITS DOCUMENTATION ARE PROVIDED
    "AS IS", WITHOUT WARRANTY OF ANY KIND, NOT EVEN THE
    IMPLIED WARRANTY OF MECHANTABILITY OR FITNESS FOR A
    PARTICULAR PURPOSE. YOU AGREE TO BEAR ALL RISKS AND
    LIABILITIES ARISING FROM THE USE OF THE SCRIPT,
    ITS DOCUMENTATION AND THE INFORMATION PROVIDED BY THE
    SCRIPTS AND THE DOCUMENTATION.

    If you cannot agree to any of the above conditions, you
    may not use the script. 
    
    Although it is not required, I would be most grateful
    if you could also link to thesitewizard.com at:

       http://www.thesitewizard.com/

*/

// ------------- CONFIGURABLE SECTION ------------------------

// $mailto - set to the email address you want the form
// sent to, eg
//$mailto		= "[email protected]" ;

$mailto = '[email protected]' ;

// $subject - set to the Subject line of the email, eg
//$subject	= "Feedback Form" ;

$subject = "Query from ITS Website" ;

// the pages to be displayed, eg
//$formurl		= "http://www.example.com/feedback.html" ;
//$errorurl		= "http://www.example.com/error.html" ;
//$thankyouurl	= "http://www.example.com/thankyou.html" ;

$formurl = "http://www.itstravel.co.uk/contact.htm" ;
$errorurl = "http://www.itstravel.co.uk/contactfailed.htm" ;
$thankyouurl = "http://www.itstravel.co.uk/thankyou.htm" ;

$uself = 0;

// -------------------- END OF CONFIGURABLE SECTION ---------------

$headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ;
$name = $_POST['name'] ;
$email = $_POST['email'] ;
$comments = $_POST['comments'] ;
$http_referrer = getenv( "HTTP_REFERER" );

if (!isset($_POST['email'])) {
header( "Location: $formurl" );
exit ;
}
if (empty($name) || empty($email) || empty($comments)) {
   header( "Location: $errorurl" );
   exit ;
}
if ( ereg( "[\r\n]", $name ) || ereg( "[\r\n]", $email ) ) {
header( "Location: $errorurl" );
exit ;
}

if (get_magic_quotes_gpc()) {
$comments = stripslashes( $comments );
}

$messageproper =

"This message was sent from:\n" .
"$http_referrer\n" .
"------------------------------------------------------------\n" .
"Name of sender: $name\n" .
"Email of sender: $email\n" .
"------------------------- COMMENTS -------------------------\n\n" .
$comments .
"\n\n------------------------------------------------------------\n" ;

mail($mailto, $subject, $messageproper,
"From: \"$name\" <$email>" . $headersep . "Reply-To: \"$name\" <$email>" . $headersep . "X-Mailer: chfeedback.php 2.08" );
header( "Location: $thankyouurl" );
exit ;

?>

 

 

Link to comment
https://forums.phpfreaks.com/topic/79260-problem-with-form/#findComment-401323
Share on other sites

thanks....

well, I don't get any error message. When hitting the submit button it just clears the form and displays the text entered inthe url bar - like this:

http://www.itstravel.co.uk/contact.htm?name=test&email=test&email=test&comments=test

 

How and where should the PHP file be changed to reflect the HTML form?

 

thanks...

Link to comment
https://forums.phpfreaks.com/topic/79260-problem-with-form/#findComment-402838
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.