Web Design Forums

HTML and CSS Help

Having problems with these web design scripting? Ask here.

problem with validation check box



Site of the Month Nominations
ENTER YOUR SITE NOW!

Reply
 
LinkBack Thread Tools
Old June 28 '09, 03:20 PM (#1)
speed is offline
New Member!
 
speed's Avatar
 
Join Date: June 2009
Posts: 4
speed is an unknown quantity at this point
problem with validation check box

Ok so i've nearly finished my site and i'm left with 2 small annoying problems. The first one is that it doesn't matter whether or not someone checks the terms and conditions checkbox, the form still submits.

The second is that when someone enters a £ sign in a field, when i recieve the email after its submitted the £ sign has a capital A with an arrow above it in front of the £ sign.



Hopefully 2 easy to fix problems, here is the code for my page. I know its bad in many ways but it works and looks fine when uploaded.



PHP Code:
<?php
ini_set
('display_errors'1);

extract($_POST);

if (!
file_exists("../config.php")) 
{
$host $_SERVER[HTTP_HOST ];
$path pathinfo($_SERVER['PHP_SELF']);
$file_path $path['dirname'];

exit;
}
include 
"../config.php";


if (
$sendto_email == "changeme@example.com")
{

exit;


if (!
eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,6}$"$senders_email))
{
$error "1";
$info_error .= $lang_invalidemail "<br>"
}
if (empty (
$security_code)) 
{
$error "1";
$info_error .= $lang_nocode "<br>"
}

if (
$terms != 1) {
if (
$senders_name != '') {
$error "1";
$info_error .= "Please accept the terms and conditions and try again"
}
}

elseif (
$security_code != $randomness
{
$error "1";
$info_error .= $lang_wrongcode "<br>"
}
if (
$showlink != "no")
{
$link "<br><span style=\"font-size: 10px;\">Powered by <a href=\"http://www.bellonline.co.uk/web-services/free/scripts/php-mailer-script/\" title=\"free PHP mailer script\">BELLonline PHP mailer script</a></span>";
}
if (
$error == "1"
{
$info_notice "<span style=\"color: " $error_colour "; font-weight: bold;\">" $lang_error "</span><br>"

if (empty (
$submit)) 
{
$info_error "";
$info_notice $lang_notice;


function 
Random() 
{
$chars "ABCDEFGHJKLMNPQRSTUVWZYZ23456789";
srand((double)microtime()*1000000);
$i 0;
$pass '' ;
while (
$i <= 4
{
$num rand() % 32;
$tmp substr($chars$num1);
$pass $pass $tmp;
$i++; 

return 
$pass
}
$random_code Random();
$mail_message stripslashes($mail_message);

print 
"<form name=\"BELLonline_email\" method=\"post\" style=\"margin: 0;\" action=\"\">


"
;

echo 
"<strong><font color=\"FF0000\">".$info_error."</font></strong>";
?>
<!--Elitetradesmen form -->

<p>To quote for this job please fill in the details below: </p>
<p><BR> 
<LABEL for="job_number">Job Number: </LABEL> 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp;&nbsp; 
<label for="your_business_name">Your Business Name: <br />
<input name="job_number" type="text" id="job_number" value="<?=$job_number;?>" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="text" id="your_business_name" name="your_business_name" value="<?=$your_business_name;?>" />
<br />
</label>
<BR> 
<label for="your_start_date">Your Start Date: </label>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Yo ur Completion Date:<BR>
<INPUT type="text" id="your_start_date" name="your_start_date" value="<?=$your_start_date;?>"> 
<label for="your_completion_date">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;
<input type="text" id="your_completion_date" name="your_completion_date" value="<?=$your_completion_date;?>"/>
<br /><br />

<label for="email">Email:</label>
<br />
<input type="text" id="senders_email" name="senders_email" value="<?=$senders_email;?>"/>
<br />
<label for="additional_information">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
</label>
Your quote with any additional information:
<br />
<textarea name="additional_information" cols="35" rows="5" id="details" name="additional_information"><?=$additional_information;?></textarea>
<br />
<BR>
<label>
<input name="terms" type="checkbox" id="terms" value="1" /> Please check the box to confirm you have read and agree to our <a href="../policies.html">Terms and conditions
</a></label>
<a href="../policies.html"><br/>
</a><br/> 


<!-- end elite tradesmen form -->


<?
// DO NOT EDIT THE BELOW
print "
Please enter the text in the box. (case sensitive): <input name=\"security_code\" type=\"text\" id=\"security_code\" size=\"5\"> 
&nbsp;&nbsp;&nbsp;&nbsp;<b>$random_code</b><input name=\"randomness\" type=\"hidden\" id=\"randomness\" value=\"$random_code\">
<p><br />
<input name=\"submit\" type=\"submit\" id=\"submit\" value=\"$lang_submit\" class=\"mailform_button\">
</form>"
;
}
else
{



if (
$checkdomain == "yes"
{
$sender_domain substr($senders_email, (strpos($senders_email'@')) +1);
$recipient_domain substr($sendto_email, (strpos($sendto_email'@')) +1);
if (
$sender_domain == $recipient_domain)
{
print 
"Sorry, you cannot send messages from this domain ($sender_domain)";
exit;

}


$info_notice $lang_sent;
/* THE FOLLOWING CODE FORMATS THE EMAIL CONTENT */
//We create a mail_message field with any POSTED FORM ELEMENT.
//To access such an element, we use the name of any form input with a 
//$ symbol before it, so for example to get their name, I use senders_name
$mail_subject "Email enquiry from Elite Tradesmen website";

$mail_message "***<b>ELITE TRADESMEN WEBSITE - QUOTE FOR WORK</b>***<br/><br/>"$mail_message ."Job Number: "$job_number "<br/><br/>Business Name: "$your_business_name "<br/><br/>Email: "$senders_email "<br/><br/>Start Date: "$your_start_date ."<br/><br/>Completion Date: "$your_completion_date ."<br/><br/>Quote with additional information: "$additional_information;

/* END CODE TO FORMAT MAIL CONTENT */


//$mail_message = stripslashes($mail_message);
$senders_email preg_replace("/[^a-zA-Z0-9s.@-_]/""-"$senders_email);
$senders_name preg_replace("/[^a-zA-Z0-9s]/"" "$senders_name);
$headers "From: $senders_name <$senders_email> \r\n";
$headers .= "MIME-Version: 1.0\r\n"
$headers .= "Content-type: text/html\r\n";
$headers .= "X-Mailer: Mailscript by Dave Hayward [URL="http://www.megaginge.info"][COLOR=#660000]http://www.megaginge.info[/COLOR][/URL] [EMAIL="megaginge@gmail.com"][COLOR=#660000]megaginge@gmail.com[/COLOR][/EMAIL] \r\n";
mail($sendto_email$mail_subject$mail_message$headers);
// THE FOLLOWING CODE SORTS THE REDIRECT TO THANKS PAGE //
?>

<script type="text/javascript">
<!--
window.location = "thankyou5.html";
//-->
</script>
<?
//END OF REDIRECT CODE

}

?>

Last edited by Wired; June 28 '09 at 03:30 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old June 28 '09, 07:45 PM (#2)
imagn is offline
WDF Regular
 
imagn's Avatar
 
Join Date: July 2007
Location: Los Angeles
Posts: 156
imagn will become famous soon enough
For the terms use:

PHP Code:
if(!isset($_POST['terms'])) {
// RUN ERROR CODE

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old July 3 '09, 02:19 AM (#3)
nitin is offline
New Member!
 
nitin's Avatar
 
Join Date: July 2009
Posts: 14
nitin is an unknown quantity at this point
I think you don't have script to redirect the particular page to log in page.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old July 3 '09, 12:19 PM (#4)
speed is offline
New Member!
 
speed's Avatar
 
Join Date: June 2009
Posts: 4
speed is an unknown quantity at this point
Worked out how to do it now, cheers guys.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

  Web Design Forums » Programming Help » HTML and CSS Help

Bookmarks


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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Slicing & "coding" problem with automatically expanding content box vattu- Adobe Photoshop Help 0 November 29 '08 12:58 AM
problem with multiple select list box! imcrapatthis HTML and CSS Help 2 March 5 '08 10:46 AM
rounded box image problem? Karloff HTML and CSS Help 4 August 30 '06 02:00 PM
problem in using check box Anant PHP 3 July 26 '05 12:17 AM
form validation problem chrisc_79 Other Languages 3 December 30 '03 03:51 PM

 
User Infomation
Your Avatar

Site Of The Month

Ticket Cake
Ticket Cake

Ticket Cake is a drupal based event ticketing platform. It features that ability to browse events and share them.

Nominate Your Site Now!

Advertisement
WolfCMS.org

Latest Articles
- by RickM
- by bfsog

Advertisement

Partner Links



All times are GMT -4. The time now is 02:36 AM.


WebDesignForums.net is Copyright © 2010 RikeMedia.

SEO by vBSEO

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163