Jump to content

TheJoey

Members
  • Posts

    334
  • Joined

  • Last visited

    Never

Everything posted by TheJoey

  1. couldnt a use of a flat file database be used, cause i cant use mysql on my hosting..
  2. When i try to use one of the href from the links i get this error ERROR 403 Access forbidden
  3. ill keep u posted its really late . thanks for your help.
  4. if i was to use session_start(); $_SESSION['shopping_cart'] = array(); // And then to add items... $_SESSION['shopping_cart'][] = "Item 1"; $_SESSION['shopping_cart'][] = "Item 2"; // And to echo them back out... foreach($_SESSION['shopping_cart'] as $value) { echo $value . "<br />"; } would i then be able to edit add and remove from cart? or would it be restricted
  5. ive seen a few examples on the net but seem very complex, what would be the easiest way to start a shopping cart that stores its data in arrays insted of a database.
  6. much thanks. yeh i was picturing doing something like that. just wasnt sure if it would work.
  7. Umm sorry, i wasnt to sure how to explain it. So ill use two different scenarios 1. Loggin in user can see all links and use the features on the website. 2. Non logged in user can browse but can only view the features.
  8. i have question about wether or not this can be done. Say i have a website with a login. And a user goes to click on something that requires a login that it will echo "refer = page" etc i am using sessions so would i just use Session([user_id]) (name of session) thanks in advance.
  9. I currently have this. if ($age <16 && $age >90) $errorAge = true; Although it doesnt display any error for age althought if i want to test the code and put if (strlen($age)<1) $errorAge = true; it displays the error i want. So im guessing its the validation technique im trying to use.
  10. if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) $errorEmail = true;[/code im getting this syntax error [code]Deprecated: Function eregi() is deprecated in C:\xampplite\htdocs\Trial\New Folder\save.php on line 88
  11. nothing new i havent determined the problem
  12. > pulling my hair out trying to work this out, its prob something stupid.
  13. it seems when i rearange function showForm($erroremail=false,$errorfname=false,$errorlname=false,$errorage=false) the error output changes from ethier email and firstname to displaying firstname and lastname but never all of them.
  14. thanks ill give it a shot. Age & Email errors still arent showing up.. mabye its the validation technique im trying to use.
  15. well i have other text fields i just dont want them validated.
  16. Its currently not displaying errors for email & age. <?php // Function to display form function showForm($erroremail=false,$errorfname=false,$errorlname=false,$errorage){ if ($erroremail) $errorTextemail = "Email must be valid"; if ($errorfname) $errorTextfname = "First name cant be empty"; if ($errorlname) $errorTextlname = "Last name cant be empty"; if ($errorage) $errorTextage = "Age must be between 16-90"; echo '<div id="center"><form action="save.php" method="POST"><table>'; // Display email field an error if needed echo '<tr><td>Email:</td><td><input type="text" name="email"></td></tr>'; if ($erroremail) echo "<tr><td colspan='2'>$errorTextemail</td></tr>"; // Display First name field an error if needed echo '<tr><td>FirstName:</td><td><input type="text" name="fname"></td></tr>'; if ($errorfname) echo "<tr><td colspan='2'>$errorTextfname</td></tr>"; // Display Last name field an error if needed echo '<tr><td>LastName:</td><td><input type="text" name="lname"></td></tr>'; if ($errorlname) echo "<tr><td colspan='2'>$errorTextlname</td></tr>"; // Display Last name field an error if needed echo '<tr><td>Age:</td><td><input type="text" name="age"></td></tr>'; if ($errorage) echo "<tr><td colspan='2'>$errorTextage</td></tr>"; echo '<tr><td>Address:</td><td><input type="text" name="address"></td></tr>'; echo '<tr><td>City:</td><td><input type="text" name="city"></td></tr>'; echo '<tr><td><input type="submit" name="SubmitForm" value="Send"></td></tr>'; echo '<form></div>'; } if (!isset($_POST['SubmitForm'])) { showForm(); } else { //Init error variables $erroremail = false; $errorfname = false; $errorlname = false; $errorage = false; $email = isset($_POST['email']) ? trim($_POST['email']) : ''; $fname = isset($_POST['fname']) ? trim($_POST['fname']) : ''; $lname = isset($_POST['lname']) ? trim($_POST['lname']) : ''; $age = isset($_POST['age']) ? trim($_POST['age']) : ''; if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) $errorEmail = true; if (strlen($fname)<1) $errorfname = true; if (strlen($lname)<1) $errorlname = true; if ($age <16 && $age >90) $errorage = true; // Display the form again as there was an error if ($erroremail || $errorfname || $errorlname || $errorage) { showForm($erroremail,$errorfname,$errorlname,$errorage); } else { $email = $_POST['email']; $fname = $_POST['fname']; $lname = $_POST['lname']; $age = $_POST['age']; $address = $_POST['address']; $city = $_POST['city']; $fp = fopen("users.txt","a"); $fp1 = fopen("data.txt","a"); if(!$fp) { echo 'Error: Cannot open file.'; exit; } fwrite($fp, $email.":".$fname."\r\n"); fwrite($fp1, $lname."||".$age."||".$address."||".$city."\r\n"); fclose($fp); echo 'Added'; } } ?>
  17. thanks guys. i ran into another problem on line 82 which has nothing on it. Parse error: syntax error, unexpected $end in C:\xampplite\htdocs\Trial\New Folder\save.php on line 82
  18. yer i used those numbers as a example but yer i want the age to be between 16-90
  19. if ($age)<16 && >90) $errorage = true; im getting error with this line of code. Parse error: syntax error, unexpected '<' in C:\xampplite\htdocs\Trial\New Folder\save.php on line 55
×
×
  • 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.