-
Posts
82 -
Joined
-
Last visited
Everything posted by spanner206
-
dont think i have set anything, never used $_SESSION before soive got no clue
-
right i put that in now im getting a undefined index on typeofbusiness
-
hi once again im in need of help what i need is a double column one with a drop down box called type of business and one hidden one with the id, to me it would seem easier to simply code all of the options in html but the options for type of columns has been coded onto the website, i got a code sent over to me but errors are occurring so just wondering if anybody has any ideas. <td>Type of Business:</td> <select name="typeofbusiness" id="typeofbusiness"> <?php $count = count($_SESSION['typeofbusiness']); for ($i = 0; $i < $count; $i++) { if($_SESSION['id'][$i]!=$_SESSION['Id']){ ?> <option value="<?php echo $_SESSION['id'][$i];?>" <?php if (isset($_REQUEST['typeofbusiness'])&&$_REQUEST['typeofbusiness']==$_SESSION['id'][$i]) { echo'selected="selected"'; }?>><?php echo $_SESSION['typeofbusiness'][$i];?></option> <?php } } ?> ( ! ) Notice: Undefined variable: _SESSION in C:\wamp\www\AddLeads\addeadstemplate.php on line 248 Call Stack # Time Memory Function Location 1 0.0000 186688 {main}( ) ..\addeadstemplate.php:0 any help will be greatly appreciated.
-
cheers for everyones help couldnt of done it without you
-
waaaaay you only gone and done it again cheers ch0cu3r now its just this the, The, THE code
-
yh that got rid of the error but if i type in the same company name twice its still going onto the database twice. any ideas???
-
hi ive tried both sets of code, the sql code is showing an error and a notice ( ! ) Notice: Undefined variable: db in C:\wamp\www\AddLeads\addeadstemplate.php on line 55 Call Stack # Time Memory Function Location 1 0.0000 189704 {main}( ) ..\addeadstemplate.php:0 ( ! ) Fatal error: Call to a member function real_escape_string() on a non-object in C:\wamp\www\AddLeads\addeadstemplate.php on line 55 Call Stack # Time Memory Function Location 1 0.0000 189704 {main}( ) ..\addeadstemplate.php:0 and the code for 'the' is just showing this once i press submit, Theakstons : PASS The Rams : FAIL - cannot begin with "The" Wetherspoons : PASS THE HAMMERS : FAIL - cannot begin with "The" knowing me i put the code in the wrong place heres what it currently looks like. the tangerines : FAIL - cannot begin with "The" <!DOCTYPE HTML> <html> <head> <style> .error {color: #FF0000;} </style> </head> <body> <?php $con = mysqli_connect("localhost","root","","nib"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } // define variables and set to empty values $companyname = $firstname = $address1 = $address2 = $county = $city = $postcode = $email = $website = $clubphone = $homephone = $mobilephone = $typeofbusiness = $renewaldate = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { $errors = array(); if (empty($_POST["companyname"])) { $errors['companyname'] = "Please Enter Your companyname"; }elseif(preg_match_all("/[(?\/<>*:.@)]/i",$_POST['companyname'],$matches)){ // list of invalid characters #echo '<pre>',print_r($matches),'</pre>'; $invalid_characters = implode(",",$matches[0]); $errors['companyname'] = 'Cannot use '.$invalid_characters; } $company_names = array ( 'Theakstons', 'The Rams', 'Wetherspoons', 'THE HAMMERS', 'the tangerines' ); foreach ($company_names as $name) { echo "$name : "; if (stripos($name, 'the ')===0) { echo 'FAIL - cannot begin with "The"<br>'; } else { echo 'PASS<br>'; } } $sql = sprintf("SELECT COUNT(*) as total FROM tbl_club_contacts WHERE companyname = '%s' ", $db->real_escape_string($companyname)); $result = $db->query($sql); $row = $result->fetch_assoc(); if ($row['total'] > 0) { $errors['companyname'] = "The name '$companyname' already exists."; } else { $companyname = test_input($_POST["companyname"]); }
-
yh tbl_club_contacts
-
yh ive been trying to sort that out my boss wanted me to block the for some reason but i dont no how i would stop that from happening
-
hi just wondering how i would go about checking if a companys name is already in use and if it is show a message at the side saying u cant use this name as its already in use, i know how i would do the error message but i got no clue on how to do the check im guessing you use a sql query but i dont really know. this is the format ive been doing my code in. if (empty($_POST["companyname"])) { $errors['companyname'] = "Please Enter Your companyname"; }elseif(preg_match_all("/[(?\/<>*:.@)]/i",$_POST['companyname'],$matches)){ // list of invalid characters #echo '<pre>',print_r($matches),'</pre>'; $invalid_characters = implode(",",$matches[0]); $errors['companyname'] = 'Cannot use '.$invalid_characters; } elseif(strlen($_POST['companyname']) > 220) { $errors['companyname'] = 'Company name must be less then 220 characters'; } elseif(strpos($_POST['companyname'], 'The') !== false) { $errors['companyname'] = 'Company Names cant start with The'; } elseif(strpos($_POST['companyname'], 'the') !== false) { $errors['companyname'] = 'Company Names cant start with the'; } elseif(strpos($_POST['companyname'], 'THE') !== false) { $errors['companyname'] = 'Company Names cant start with THE'; } else { $companyname = test_input($_POST["companyname"]); }
-
you've done it again ch0cu3r thanks again m8
-
another beginners question from yours truly but i was just wondering how i would code a character limit on one of my fields iv been around the internet but i cant find what i need cause i usually come up with the same error code each time. if anyone knows what to do that would be great, hears the code iv been using. <?php $con = mysqli_connect("localhost","root","","nib"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } // define variables and set to empty values $companyname = $firstname = $address1 = $address2 = $area = $city = $postcode = $email = $website = $clubphone = $homephone = $mobilephone = $typeofbusiness = $renewaldate = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { $errors = array(); if (empty($_POST["companyname"])) { $errors['companyname'] = "Please Enter Your companyname"; } <input type='text' name='keywords' size='60' value='companyname' maxlength='10' /> elseif(strpos($_POST['companyname'], '/') !== false) { $errors['companyname'] = 'Cannot use /'; } elseif(strpos($_POST['companyname'], 'The') !== false) { $errors['companyname'] = 'Company Names cant start with The'; } elseif(strpos($_POST['companyname'], 'the') !== false) { $errors['companyname'] = 'Company Names cant start with the'; } elseif(strpos($_POST['companyname'], 'THE') !== false) { $errors['companyname'] = 'Company Names cant start with THE'; } else { $companyname = test_input($_POST["companyname"]); } and heres the error code ive been getting. ( ! ) Parse error: syntax error, unexpected '<' in C:\wamp\www\AddLeads\addeadstemplate.php on line 29 aswell as this if i remove this symbol i get one to do with the else if statement witch i kinda need. again if anyone has a solution please get back to me soon as
-
forget that i cocked up like an idiot but ive finally realised after 3 hours that i was working on the wrong save file but sorted it now cheers for everyones help
- 10 replies
-
- special
- characters
-
(and 3 more)
Tagged with:
-
just tryed both and they both dont seemed to work
- 10 replies
-
- special
- characters
-
(and 3 more)
Tagged with:
-
hi i want one of my fields to only be a-z and for a message to show saying this if someone types in numbers or special characters, ive tried putting it on the field company name but it dosent work so i was just wondering what you think?? <!DOCTYPE HTML> <html> <head> <style> .error {color: #FF0000;} </style> </head> <body> <?php $con = mysqli_connect("localhost","root","","nib"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } // define variables and set to empty values $companyname = $firstname = $address1 = $address2 = $area = $city = $postcode = $email = $website = $clubphone = $homephone = $mobilephone = $typeofbusiness = $renewaldate = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { $errors = array(); // a / was found if (empty($_POST["companyname"])) { $errors['companyname'] = "please enter your companys name"; } elseif if ( !preg_match ("/^[a-zA-Z\s]+$/",$companyname)) { $errors[] = "Name must only contain letters!"; else { $companyname = test_input($_POST["companyname"]); } if (empty($_POST["typeofbusiness"])) {$errors['typeofbusiness'] = "please enter your TypeofBusiness";} else {$typeofbusiness = test_input($_POST["typeofbusiness"]);} if (empty($_POST["firstname"])) { $errors['firstname'] = "Please Enter Your First Name"; } else { $firstname = test_input($_POST["firstname"]); } if (empty($_POST["address1"])) {$errors['address1'] = "Please Enter Address 1";} else {$address1 = test_input($_POST["address1"]);} if (empty($_POST["address2"])) {$address2 = test_input($_POST["address2"]);} if (empty($_POST["area"])) {$errors['area'] = "Please enter Area";} else {$area = test_input($_POST["area"]);} if (empty($_POST["city"])) {$errors['city'] = "Please Enter City";} else {$city = test_input($_POST["city"]);} if (empty($_POST["postcode"])) {$errors['postcode'] = "Please enter your PostCode";} else {$postcode = test_input($_POST["postcode"]);} if (empty($_POST["email"])) {$errors['email'] = "Please enter your Email";} else {$email = test_input($_POST["email"]);} if (empty($_POST["website"])) {$errors['website'] = "Please Enter your Website";} else {$Website = test_input($_POST["website"]);} if (empty($_POST["clubphone"])) {$errors['clubphone'] = "Please enter your club number";} else {$clubphone = test_input($_POST["clubphone"]);} if (empty($_POST["homephone"])) {$errors['homephone'] = "Please enter your home number";} else {$homephone = test_input($_POST["homephone"]);} if (empty($_POST["mobilephone"])) {$errors['mobilephone'] = "Please enter your mobile number";} else {$mobilephone = test_input($_POST["mobilephone"]);} if (empty($_POST["renewaldate"])) {$errors['renewaldate'] = "Please enter your mobile number";} else {$renewaldate = test_input($_POST["renewaldate"]);} function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } } ?> <h2>Add Leads</h2> <p><span class="error">* required field.</span></p> <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> <table border = "0"> <tr> <td>Company Name:</td><td> <input type="text(220)" name="companyname"></td> <td><span class="error">* <?php if (isset($errors['companyname'])) echo $errors['companyname']; ?></span></td> </tr> <tr> <td>Type of Business:</td><td> <input type="text" name="typeofbusiness"></td> <td><span class="error">* <?php if (isset($errors['typeofbusiness'])) echo $errors['typeofbusiness']; ?></span></td> </tr> <tr> <td>First Name:</td><td> <input type="text" name="firstname"></td> <td><span class="error">* <?php if (isset($errors['firstname'])) echo $errors['firstname']; ?></span></td> </tr> <tr> <td>Address 1:</td><td> <input type="text" name="address1"></td> <td><span class="error">* <?php if (isset($errors['address1'])) echo $errors['address1']; ?></span></td> </tr> <tr> <td>Address 2:</td><td><input type="text" name="address2"></td> </tr> <tr> <td>Area:</td> <td><input type="text" name="area"></td> <td><span class="error">* <?php if (isset($errors['area'])) echo $errors['area']; ?></span></td> </tr> <tr> <td>Post Code:</td> <td><input type="text" name="postcode"></td> <td><span class="error">* <?php if (isset($errors['postcode'])) echo $errors['postcode']; ?></span></td> </tr> <tr> <td>City:</td> <td><input type="text" name="city"></td> <td><span class="error">* <?php if (isset($errors['city'])) echo $errors['city']; ?></span></td> </tr> <tr> <td>Email:</td> <td><input type="text" name="email"></td> <td><span class="error">* <?php if (isset($errors['email'])) echo $errors['email']; ?></span></td> </tr> <tr> <td>Website:</td> <td><input type="text" name="website"></td> <td><span class="error">* <?php if (isset($errors['website'])) echo $errors['website']; ?></span></td> </tr> <tr> <td>Club phone:</td> <td><input type="integer" name="clubphone"></td> <td><span class="error">* <?php if (isset($errors['clubphone'])) echo $errors['clubphone']; ?></span></td> </tr> <tr> <td>Home phone:</td> <td><input type="integer" name="homephone"></td> <td><span class="error">* <?php if (isset($errors['homephone'])) echo $errors['homephone']; ?></span></td> </tr> <tr> <td>Mobile Phone:</td> <td><input type="integer" name="mobilephone"></td> <td><span class="error">* <?php if (isset($errors['mobilephone'])) echo $errors['mobilephone']; ?></span></td> </tr> <tr> <td>Renewal Date:</td> <td><input type="date" name="renewaldate"></td> <td><span class="error">* <?php if (isset($errors['renewaldate'])) echo $errors['renewaldate']; ?></span></td> </tr> <tr> <td><input type="submit" name="submit" value="Submit"></td> </tr> <?php if($_SERVER['REQUEST_METHOD'] == "POST" && count($errors) == 0) { // Do it { $con = mysqli_connect("localhost","root","","nib"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $sql="INSERT INTO tbl_club_contacts (CompanyName, FirstName, Address1, Address2, Area, City, PostCode, Email, Website, ClubPhone, HomePhone, MobilePhone, TypeofBusiness, RenewalDate ) VALUES ('$_POST[companyname]','$_POST[firstname]','$_POST[address1]','$_POST[address2]','$_POST[area]','$_POST[city]','$_POST[postcode]','$_POST[email]','$_POST[website]','$_POST[clubphone]','$_POST[homephone]','$_POST[mobilephone]','$_POST[typeofbusiness]','$_POST[renewaldate]')"; if (!mysqli_query($con,$sql)) { die('Error: ' . mysqli_error($con)); echo "record added"; } mysqli_close($con); } // end if $errors == 0 } ?> </form> </body> </html>
-
ive put that in and it dosent seem to work
- 10 replies
-
- special
- characters
-
(and 3 more)
Tagged with:
-
shall i wrap this round the whole of the php
- 10 replies
-
- special
- characters
-
(and 3 more)
Tagged with:
-
yh i want to block / only sorry about that
- 10 replies
-
- special
- characters
-
(and 3 more)
Tagged with:
-
hi ive been researching this all morning but i cant seem to find much, what i want to do is disable special characters and if anybody trys to type one in a message box will appear saying "special characters are not available" or something like that. i know that you cant do message boxes in php so i was wondering how i would do it in javascript/visual basic, i roughly no how to do it in visual basic but i dont know where i would put it in the code. <!DOCTYPE HTML> <html> <head> <style> .error {color: #FF0000;} </style> </head> <body> <?php $con = mysqli_connect("localhost","root","","nib"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } // define variables and set to empty values $companyname = $firstname = $address1 = $address2 = $area = $city = $postcode = $email = $website = $clubphone = $homephone = $mobilephone = $typeofbusiness = $renewaldate = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { $errors = array(); if (empty($_POST["companyname"])) {$errors['companyname'] = "please enter your companys name";} else {$companyname = test_input($_POST["companyname"]);} if (empty($_POST["typeofbusiness"])) {$errors['typeofbusiness'] = "please enter your TypeofBusiness";} else {$typeofbusiness = test_input($_POST["typeofbusiness"]);} if (empty($_POST["firstname"])) {$errors['firstname'] = "Please Enter Your First Name";} else {$firstname = test_input($_POST["firstname"]);} if (empty($_POST["address1"])) {$errors['address1'] = "Please Enter Address 1";} else {$address1 = test_input($_POST["address1"]);} if (empty($_POST["address2"])) {$address2 = test_input($_POST["address2"]);} if (empty($_POST["area"])) {$errors['area'] = "Please enter Area";} else {$area = test_input($_POST["area"]);} if (empty($_POST["city"])) {$errors['city'] = "Please Enter City";} else {$city = test_input($_POST["city"]);} if (empty($_POST["postcode"])) {$errors['postcode'] = "Please enter your PostCode";} else {$postcode = test_input($_POST["postcode"]);} if (empty($_POST["email"])) {$errors['email'] = "Please enter your Email";} else {$email = test_input($_POST["email"]);} if (empty($_POST["website"])) {$errors['website'] = "Please Enter your Website";} else {$Website = test_input($_POST["website"]);} if (empty($_POST["clubphone"])) {$errors['clubphone'] = "Please enter your club number";} else {$clubphone = test_input($_POST["clubphone"]);} if (empty($_POST["homephone"])) {$errors['homephone'] = "Please enter your home number";} else {$homephone = test_input($_POST["homephone"]);} if (empty($_POST["mobilephone"])) {$errors['mobilephone'] = "Please enter your mobile number";} else {$mobilephone = test_input($_POST["mobilephone"]);} if (empty($_POST["renewaldate"])) {$errors['renewaldate'] = "Please enter your mobile number";} else {$renewaldate = test_input($_POST["renewaldate"]);} } function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } ?> <h2>Add Leads</h2> <p><span class="error">* required field.</span></p> <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> <table border = "0"> <tr> <td>Company Name:</td><td> <input type="text(220)" name="companyname"></td> <td><span class="error">* <?php if (isset($errors['companyname'])) echo $errors['companyname']; ?></span></td> </tr> <tr> <td>Type of Business:</td><td> <input type="text" name="typeofbusiness"></td> <td><span class="error">* <?php if (isset($errors['typeofbusiness'])) echo $errors['typeofbusiness']; ?></span></td> </tr> <tr> <td>First Name:</td><td> <input type="text" name="firstname"></td> <td><span class="error">* <?php if (isset($errors['firstname'])) echo $errors['firstname']; ?></span></td> </tr> <tr> <td>Address 1:</td><td> <input type="text" name="address1"></td> <td><span class="error">* <?php if (isset($errors['address1'])) echo $errors['address1']; ?></span></td> </tr> <tr> <td>Address 2:</td><td><input type="text" name="address2"></td> </tr> <tr> <td>Area:</td> <td><input type="text" name="area"></td> <td><span class="error">* <?php if (isset($errors['area'])) echo $errors['area']; ?></span></td> </tr> <tr> <td>Post Code:</td> <td><input type="text" name="postcode"></td> <td><span class="error">* <?php if (isset($errors['postcode'])) echo $errors['postcode']; ?></span></td> </tr> <tr> <td>City:</td> <td><input type="text" name="city"></td> <td><span class="error">* <?php if (isset($errors['city'])) echo $errors['city']; ?></span></td> </tr> <tr> <td>Email:</td> <td><input type="text" name="email"></td> <td><span class="error">* <?php if (isset($errors['email'])) echo $errors['email']; ?></span></td> </tr> <tr> <td>Website:</td> <td><input type="text" name="website"></td> <td><span class="error">* <?php if (isset($errors['website'])) echo $errors['website']; ?></span></td> </tr> <tr> <td>Club phone:</td> <td><input type="integer" name="clubphone"></td> <td><span class="error">* <?php if (isset($errors['clubphone'])) echo $errors['clubphone']; ?></span></td> </tr> <tr> <td>Home phone:</td> <td><input type="integer" name="homephone"></td> <td><span class="error">* <?php if (isset($errors['homephone'])) echo $errors['homephone']; ?></span></td> </tr> <tr> <td>Mobile Phone:</td> <td><input type="integer" name="mobilephone"></td> <td><span class="error">* <?php if (isset($errors['mobilephone'])) echo $errors['mobilephone']; ?></span></td> </tr> <tr> <td>Renewal Date:</td> <td><input type="date" name="renewaldate"></td> <td><span class="error">* <?php if (isset($errors['renewaldate'])) echo $errors['renewaldate']; ?></span></td> </tr> <tr> <td><input type="submit" name="submit" value="Submit"></td> </tr> <?php if($_SERVER['REQUEST_METHOD'] == "POST" && count($errors) == 0) { // Do it { $con = mysqli_connect("localhost","root","","nib"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $sql="INSERT INTO tbl_club_contacts (CompanyName, FirstName, Address1, Address2, Area, City, PostCode, Email, Website, ClubPhone, HomePhone, MobilePhone, TypeofBusiness, RenewalDate ) VALUES ('$_POST[companyname]','$_POST[firstname]','$_POST[address1]','$_POST[address2]','$_POST[area]','$_POST[city]','$_POST[postcode]','$_POST[email]','$_POST[website]','$_POST[clubphone]','$_POST[homephone]','$_POST[mobilephone]','$_POST[typeofbusiness]','$_POST[renewaldate]')"; if (!mysqli_query($con,$sql)) { die('Error: ' . mysqli_error($con)); echo "record added"; } mysqli_close($con); } // end if $errors == 0 } ?> </form> </body> </html>
- 10 replies
-
- special
- characters
-
(and 3 more)
Tagged with:
-
lol i got a U in maths so im not suprised cheers for all your help m8.
-
that's removed all of the errors but now its not submitting data into my database, any ideas? <!DOCTYPE HTML> <html> <head> <style> .error {color: #FF0000;} </style> </head> <body> <?php $con = mysqli_connect("localhost","root","","nib"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } // define variables and set to empty values $companyname = $firstname = $address1 = $address2 = $area = $city = $postcode = $email = $website = $clubphone = $homephone = $mobilephone = $typeofbusiness = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { $errors = array(); if (empty($_POST["companyname"])) {$errors['companyname'] = "please enter your companys name";} else {$companyname = test_input($_POST["companyname"]);} if (empty($_POST["typeofbusiness"])) {$errors['typeofbusiness'] = "please enter your TypeofBusiness";} else {$typeofbusiness = test_input($_POST["typeofbusiness"]);} if (empty($_POST["firstname"])) {$errors['firstname'] = "Please Enter Your First Name";} else {$firstname = test_input($_POST["firstname"]);} if (empty($_POST["address1"])) {$errors['address1'] = "Please Enter Address 1";} else {$address1 = test_input($_POST["address1"]);} if (empty($_POST["address2"])) {$address2 = test_input($_POST["address2"]);} if (empty($_POST["area"])) {$errors['area'] = "Please enter Area";} else {$area = test_input($_POST["area"]);} if (empty($_POST["city"])) {$errors['city'] = "Please Enter City";} else {$city = test_input($_POST["city"]);} if (empty($_POST["postcode"])) {$errors['postcode'] = "Please enter your PostCode";} else {$postcode = test_input($_POST["postcode"]);} if (empty($_POST["email"])) {$errors['email'] = "Please enter your Email";} else {$email = test_input($_POST["email"]);} if (empty($_POST["Website"])) {$errors['Website'] = "Please Enter your Website";} else {$Website = test_input($_POST["Website"]);} if (empty($_POST["ClubNumber"])) {$errors['clubnumber'] = "Please enter your club number";} else {$website = test_input($_POST["clubphone"]);} if (empty($_POST["HomeNumber"])) {$errors['homenumber'] = "Please enter your home number";} else {$website = test_input($_POST["homephone"]);} if (empty($_POST["MobileNumber"])) {$errors['mobilenumber'] = "Please enter your mobile number";} else {$website = test_input($_POST["mobilephone"]);} } function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } ?> <h2>Add Leads</h2> <p><span class="error">* required field.</span></p> <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> <table border = "0"> <tr> <td>Company Name:</td><td> <input type="text" name="companyname"></td> <td><span class="error">* <?php if (isset($errors['companyname'])) echo $errors['companyname']; ?></span></td> </tr> <tr> <td>type of business:</td><td> <input type="text" name="typeofbusiness"></td> <td><span class="error">* <?php if (isset($errors['companyname'])) echo $errors['companyname']; ?></span></td> </tr> <tr> <td>First Name:</td><td> <input type="text" name="firstname"></td> <td><span class="error">* <?php if (isset($errors['firstname'])) echo $errors['firstname']; ?></span></td> </tr> <tr> <td>Address 1:</td><td> <input type="text" name="address1"></td> <td><span class="error">* <?php if (isset($errors['address1'])) echo $errors['address1']; ?></span></td> </tr> <tr> <td>Address 2:</td><td><input type="text" name="address2"></td> </tr> <tr> <td>Area:</td> <td><input type="text" name="area"></td> <td><span class="error">* <?php if (isset($errors['area'])) echo $errors['area']; ?></span></td> </tr> <tr> <td>PostCode:</td> <td><input type="text" name="postcode"></td> <td><span class="error">* <?php if (isset($errors['postcode'])) echo $errors['postcode']; ?></span></td> </tr> <tr> <td>City:</td> <td><input type="text" name="city"></td> <td><span class="error">* <?php if (isset($errors['city'])) echo $errors['city']; ?></span></td> </tr> <tr> <td>Email:</td> <td><input type="text" name="email"></td> <td><span class="error">* <?php if (isset($errors['email'])) echo $errors['email']; ?></span></td> </tr> <tr> <td>Website:</td> <td><input type="text" name="website"></td> <td><span class="error">* <?php if (isset($errors['website'])) echo $errors['website']; ?></span></td> </tr> <tr> <td>Club phone:</td> <td><input type="text" name="clubphone"></td> <td><span class="error">* <?php if (isset($errors['clubphone'])) echo $errors['clubphone']; ?></span></td> </tr> <tr> <td>home phone:</td> <td><input type="text" name="homephone"></td> <td><span class="error">* <?php if (isset($errors['homephone'])) echo $errors['homephone']; ?></span></td> </tr> </tr> <tr> <td>mobile phone:</td> <td><input type="text" name="mobilephone"></td> <td><span class="error">* <?php if (isset($errors['mobilephone'])) echo $errors['mobilephone']; ?></span></td> </tr> <tr> <td><input type="submit" name="submit" value="Submit"></td> </tr> <?php if($_SERVER['REQUEST_METHOD'] == "POST" && count($errors) == 0) { // Do it { $con = mysqli_connect("localhost","root","","nib"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $sql="INSERT INTO tbl_club_contacts (CompanyName, FirstName, Address1, Address2, Area, City, PostCode, Email, Website, ClubPhone, HomePhone, MobilePhone ) VALUES ('$_POST[companyname]','$_POST[firstname]','$_POST[address1]','$_POST[address2]','$_POST[area]','$_POST[city]','$_POST[postcode]','$_POST[email]','$_POST[website]','$_POST[clubphone]','$_POST[homephone]','$_POST[mobilephone]','$_POST[typeofbusiness]')"; if (!mysqli_query($con,$sql)) { die('Error: ' . mysqli_error($con)); echo "record added"; } mysqli_close($con); } // end if $errors == 0 } ?> </form> </body> </html>
-
right thats one down, now its all the ones on row 174 any ideas <?php if($_SERVER['REQUEST_METHOD'] == "POST" && count($errors) == 0) { // Do it } { $con = mysqli_connect("localhost","root","","nib"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $sql="INSERT INTO tbl_club_contacts (CompanyName, FirstName, Address1, Address2, Area, City, PostCode, Email, Website, ClubPhone, HomePhone, MobilePhone ) VALUES ('$_POST[companyname]','$_POST[firstname]','$_POST[address1]','$_POST[address2]','$_POST[area]','$_POST[city]','$_POST[postcode]','$_POST[email]','$_POST[website]','$_POST[clubphone]','$_POST[homephone]','$_POST[mobilephone]','$_POST[typeofbusiness]')"; if (!mysqli_query($con,$sql)) { die('Error: ' . mysqli_error($con)); echo "record added"; } mysqli_close($con); } // end if $errors == 0 ?> </form> </body> </html>
-
is this in the right position because its still coming up with the same errors if (count($errors)==0) { $con = mysqli_connect("localhost","root","","nib"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } if($_SERVER['REQUEST_METHOD'] == "POST" && count($errors) == 0) { // Do it } $sql="INSERT INTO tbl_club_contacts (CompanyName, FirstName, Address1, Address2, Area, City, PostCode, Email, Website, ClubPhone, HomePhone, MobilePhone ) VALUES ('$_POST[companyname]','$_POST[firstname]','$_POST[address1]','$_POST[address2]','$_POST[area]','$_POST[city]','$_POST[postcode]','$_POST[email]','$_POST[website]','$_POST[clubphone]','$_POST[homephone]','$_POST[mobilephone]','$_POST[typeofbusiness]')"; if (!mysqli_query($con,$sql)) { die('Error: ' . mysqli_error($con)); echo "record added"; } mysqli_close($con); } // end if $errors == 0 ?> </form> </body> </html>
-
so where else should i define it?
-
hi ive encountered around 15 problems at once but just about all of them are on the same row <!DOCTYPE HTML> <html> <head> <style> .error {color: #FF0000;} </style> </head> <body> <?php $con = mysqli_connect("localhost","root","","nib"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } // define variables and set to empty values $companyname = $firstname = $address1 = $address2 = $area = $city = $postcode = $email = $website = $clubphone = $homephone = $mobilephone = $typeofbusiness = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST["companyname"])) {$errors['companyname'] = "please enter your companys name";} else {$companyname = test_input($_POST["companyname"]);} if (empty($_POST["typeofbusiness"])) {$errors['typeofbusiness'] = "please enter your TypeofBusiness";} else {$typeofbusiness = test_input($_POST["typeofbusiness"]);} if (empty($_POST["firstname"])) {$errors['firstname'] = "Please Enter Your First Name";} else {$firstname = test_input($_POST["firstname"]);} if (empty($_POST["address1"])) {$errors['address1'] = "Please Enter Address 1";} else {$address1 = test_input($_POST["address1"]);} if (empty($_POST["address2"])) {$address2 = test_input($_POST["address2"]);} if (empty($_POST["area"])) {$errors['area'] = "Please enter Area";} else {$area = test_input($_POST["area"]);} if (empty($_POST["city"])) {$errors['city'] = "Please Enter City";} else {$city = test_input($_POST["city"]);} if (empty($_POST["postcode"])) {$errors['postcode'] = "Please enter your PostCode";} else {$postcode = test_input($_POST["postcode"]);} if (empty($_POST["email"])) {$errors['email'] = "Please enter your Email";} else {$email = test_input($_POST["email"]);} if (empty($_POST["Website"])) {$errors['Website'] = "Please Enter your Website";} else {$Website = test_input($_POST["Website"]);} if (empty($_POST["ClubNumber"])) {$errors['clubnumber'] = "Please enter your club number";} else {$website = test_input($_POST["clubphone"]);} if (empty($_POST["HomeNumber"])) {$errors['homenumber'] = "Please enter your home number";} else {$website = test_input($_POST["homephone"]);} if (empty($_POST["MobileNumber"])) {$errors['mobilenumber'] = "Please enter your mobile number";} else {$website = test_input($_POST["mobilephone"]);} } function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } ?> <h2>Add Leads</h2> <p><span class="error">* required field.</span></p> <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> <table border = "0"> <tr> <td>Company Name:</td><td> <input type="text" name="companyname"></td> <td><span class="error">* <?php if (isset($errors['companyname'])) echo $errors['companyname']; ?></span></td> </tr> <tr> <td>type of business:</td><td> <input type="text" name="typeofbusiness"></td> <td><span class="error">* <?php if (isset($errors['companyname'])) echo $errors['companyname']; ?></span></td> </tr> <tr> <td>First Name:</td><td> <input type="text" name="firstname"></td> <td><span class="error">* <?php if (isset($errors['firstname'])) echo $errors['firstname']; ?></span></td> </tr> <tr> <td>Address 1:</td><td> <input type="text" name="address1"></td> <td><span class="error">* <?php if (isset($errors['address1'])) echo $errors['address1']; ?></span></td> </tr> <tr> <td>Address 2:</td><td><input type="text" name="address2"></td> </tr> <tr> <td>Area:</td> <td><input type="text" name="area"></td> <td><span class="error">* <?php if (isset($errors['area'])) echo $errors['area']; ?></span></td> </tr> <tr> <td>PostCode:</td> <td><input type="text" name="postcode"></td> <td><span class="error">* <?php if (isset($errors['postcode'])) echo $errors['postcode']; ?></span></td> </tr> <tr> <td>City:</td> <td><input type="text" name="city"></td> <td><span class="error">* <?php if (isset($errors['city'])) echo $errors['city']; ?></span></td> </tr> <tr> <td>Email:</td> <td><input type="text" name="email"></td> <td><span class="error">* <?php if (isset($errors['email'])) echo $errors['email']; ?></span></td> </tr> <tr> <td>Website:</td> <td><input type="text" name="website"></td> <td><span class="error">* <?php if (isset($errors['website'])) echo $errors['website']; ?></span></td> </tr> <tr> <td>Club phone:</td> <td><input type="text" name="clubphone"></td> <td><span class="error">* <?php if (isset($errors['clubphone'])) echo $errors['clubphone']; ?></span></td> </tr> <tr> <td>home phone:</td> <td><input type="text" name="homephone"></td> <td><span class="error">* <?php if (isset($errors['homephone'])) echo $errors['homephone']; ?></span></td> </tr> </tr> <tr> <td>mobile phone:</td> <td><input type="text" name="mobilephone"></td> <td><span class="error">* <?php if (isset($errors['mobilephone'])) echo $errors['mobilephone']; ?></span></td> </tr> <tr> <td><input type="submit" name="submit" value="Submit"></td> </tr> <?php if (count($errors)==0) { $con = mysqli_connect("localhost","root","","nib"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $sql="INSERT INTO tbl_club_contacts (CompanyName, FirstName, Address1, Address2, Area, City, PostCode, Email, Website, ClubPhone, HomePhone, MobilePhone ) VALUES ('$_POST[companyname]','$_POST[firstname]','$_POST[address1]','$_POST[address2]','$_POST[area]','$_POST[city]','$_POST[postcode]','$_POST[email]','$_POST[website]','$_POST[clubphone]','$_POST[homephone]','$_POST[mobilephone]','$_POST[typeofbusiness]')"; if (!mysqli_query($con,$sql)) { die('Error: ' . mysqli_error($con)); echo "record added"; } mysqli_close($con); } // end if $errors == 0 ?> </form> </body> </html> and the errors ( ! ) Notice: Undefined variable: errors in C:\wamp\www\AddLeads\addeadstemplate.php on line 161 Call Stack # Time Memory Function Location 1 0.0000 166344 {main}( ) ..\addeadstemplate.php:0 ( ! ) Notice: Undefined index: companyname in C:\wamp\www\AddLeads\addeadstemplate.php on line 172 Call Stack # Time Memory Function Location 1 0.0000 166344 {main}( ) ..\addeadstemplate.php:0 ( ! ) Notice: Undefined index: firstname in C:\wamp\www\AddLeads\addeadstemplate.php on line 172 Call Stack # Time Memory Function Location 1 0.0000 166344 {main}( ) ..\addeadstemplate.php:0 ( ! ) Notice: Undefined index: address1 in C:\wamp\www\AddLeads\addeadstemplate.php on line 172 Call Stack # Time Memory Function Location 1 0.0000 166344 {main}( ) ..\addeadstemplate.php:0 ( ! ) Notice: Undefined index: address2 in C:\wamp\www\AddLeads\addeadstemplate.php on line 172 Call Stack # Time Memory Function Location 1 0.0000 166344 {main}( ) ..\addeadstemplate.php:0 ( ! ) Notice: Undefined index: area in C:\wamp\www\AddLeads\addeadstemplate.php on line 172 Call Stack # Time Memory Function Location 1 0.0000 166344 {main}( ) ..\addeadstemplate.php:0 ( ! ) Notice: Undefined index: city in C:\wamp\www\AddLeads\addeadstemplate.php on line 172 Call Stack # Time Memory Function Location 1 0.0000 166344 {main}( ) ..\addeadstemplate.php:0 ( ! ) Notice: Undefined index: postcode in C:\wamp\www\AddLeads\addeadstemplate.php on line 172 Call Stack # Time Memory Function Location 1 0.0000 166344 {main}( ) ..\addeadstemplate.php:0 ( ! ) Notice: Undefined index: email in C:\wamp\www\AddLeads\addeadstemplate.php on line 172 Call Stack # Time Memory Function Location 1 0.0000 166344 {main}( ) ..\addeadstemplate.php:0 ( ! ) Notice: Undefined index: website in C:\wamp\www\AddLeads\addeadstemplate.php on line 172 Call Stack # Time Memory Function Location 1 0.0000 166344 {main}( ) ..\addeadstemplate.php:0 ( ! ) Notice: Undefined index: clubphone in C:\wamp\www\AddLeads\addeadstemplate.php on line 172 Call Stack # Time Memory Function Location 1 0.0000 166344 {main}( ) ..\addeadstemplate.php:0 ( ! ) Notice: Undefined index: homephone in C:\wamp\www\AddLeads\addeadstemplate.php on line 172 Call Stack # Time Memory Function Location 1 0.0000 166344 {main}( ) ..\addeadstemplate.php:0 ( ! ) Notice: Undefined index: mobilephone in C:\wamp\www\AddLeads\addeadstemplate.php on line 172 Call Stack # Time Memory Function Location 1 0.0000 166344 {main}( ) ..\addeadstemplate.php:0 ( ! ) Notice: Undefined index: typeofbusiness in C:\wamp\www\AddLeads\addeadstemplate.php on line 172 Call Stack # Time Memory Function Location 1 0.0000 166344 {main}( ) ..\addeadstemplate.php:0 Error: Column count doesn't match value count at row 1 if anyone can help please get back to me soon as