Jump to content

spiderwell

Members
  • Posts

    1,008
  • Joined

  • Last visited

Everything posted by spiderwell

  1. the error is reporting a php error, but i can't see any php as you only posted up javascript, this is why I am confused. is this the 'raw' php file or the output of the php?
  2. firstly I think some code of your current navigation might give us something to work on. I almost always make my navigation with list items <li>somepage link</li> A simple way to do it would be to have a querystring passing a value that triggers an include for the submenu <?php $product = $_GET['product']; ?> <ul> <li><a href="shoes.php?product=shoes">Shoes</a></li> <?php if ($product =="shoes") { // have submenu here, a nested list would work in this instance } ?> <li><a href="socks.php?product=shoes">Socks</a></li> </ul>
  3. I havent tested it, but wont this work too? if ((strtoupper($_POST['state']) == 'GA') || (empty($_POST['state']))) { exit(); // Or post error to let the user know then exit } else {
  4. i don't see the php code, just javascript?
  5. have you echoed out your sql statement to check exactly what it is doing?
  6. do you mean double click the text and it turns into a form input, as thats done via jquery simply enough with the appropriate plugin. look here for tutorial
  7. keep the trim() that cuts off white space on the inputted data at the ends of i.e. " my name " become "my name" there is a validate email function, but it isnt built into php, you need to make a regular expression check against the input, I would say learning how to write one might be a bit hard, they aren't the easiest things in php (for me at least) here's one i prepared eariler as they say: function validateEmail($themail){ $result = preg_match ("/^[^@ ]+@[^@ ]+\.[^@ \.]+$/", $themail ); if ($result){ return true; }else{ return false; } } stick that in the top of your php and then use it later on in your validation, its a function that returns true if email is valid, false if not if (Trim($State)=="") $validationOK=false; if (!validateEmail($EmailFrom)) $validationOK=false;
  8. heya buddy hows the assignment coming along! use some simple formating of html into your echoed php. here i have turned it into a list for you <?php $order = null; for($i=0; $i < count($_POST["Markets"]); $i++) { $markets .= "<li>" . $_POST["Markets"][$i] . "</li>"; } if(!is_null($markets)) { echo "Your Selected Markets are: <ul> " . $markets . "</ul>"; } else { echo "order = no selection made"; }?>
  9. testing in different browsers shouldn't be relevant when using PHP, also I would say that you haven't really done anything wrong in your code, it all works and validates how you want it to, thats a lot bette rthan some people can manage. I don't think you need to worry about using stripslashes(), its not really needed when validating input from a form directly into an email format. it was really the partner to addslashes() which is used to escape certain characters in a string especially in conjunction with inputs into databases to stop SQL querys breaking. looking at your form I would say it works fine, but the validation is moderate to low, by that I mean you only check a few variables for having an entry and thats all. I guess it depends on the needs of your client how far you can go with this, but it is possible to validate to almost any specification, obvious ones being telephone numbers, emails, addresses all having only the right data, e.g. numbers only, text only, email is an email address . php can do redirects rather than sending a refresh header using header('Location: http://www.example.com/'), not sure if you knew that one or not. otherwise I would say well done on creating a sucessful script. [ code ] put scripts in here [ / code ]
  10. did it work for ya?
  11. do you know how to retrieve form data into a variable? I would start there then write those variables to a text file, there are many many file writing examples to choose from out there.
  12. someone slap me please
  13. preventing submission unless checked is really a javascript issue not php
  14. use str_replace() or substr_replace()
  15. reg expres or explode
  16. it should work if you replace the '' around the variable in the sql with ``
  17. i think he typoed in the echo statement, remove the $ from echo $_SESSION['$myusername'] so it is $_SESSION['username']
  18. element by Id is unique so it will only pick up 1? perhaps change id to name? then use name which is an array like imageBoxes[] this isnt a solution, more me chucking out ideas and thoughts javascript is the enemy in my mind, lol
  19. ok posting it here too, but have emailed you the scripts direct. I re wrote it so that the file will work for any user in any user folder, which is the best way to do it really check_login.php <?php // Require the information from the includes.php page require_once('../config.php3'); // Connect to the server and select the database. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db")or die("Unable to select database"); // $loginusername = false; $loginpassword = false; $err = false; // default error message is empty // The username and password sent from login.php //the isset() basically means if its there get it, otherwise dont bother if (isset($_POST['username'])) $loginusername=$_POST['username']; if (isset($_POST['password']))$loginpassword=$_POST['password']; // if either isnt filled in, tell the user, a very basic bit of validation if (!$loginusername || !$loginpassword) $err = "please complete the form"; if (!$err) //if no error continue { //The following bit of coding protects from MySQL injection attacks $loginusername = stripslashes($loginusername); $loginpassword = stripslashes($loginpassword); $loginusername = mysql_real_escape_string($loginusername); $loginpassword = mysql_real_escape_string($loginpassword); //you could add other things like check for text only blah blah $sql="SELECT * FROM $tbl WHERE username='$loginusername' and password='$loginpassword'"; $result=mysql_query($sql); // Count how many results were pulled from the table $count=mysql_num_rows($result); // If the result equals 1, continue if($count==1) { session_start(); $_SESSION['user'] = $loginusername; // store session data //please see I have used a session variable that is generic not specific, otherwise you will have to make this page different for every user //that would be a pain in the ass, you don't need to have user1 or user2, its the value stored that relevant, not what the variable name is header("Location: ../{$loginusername}/index.php3"); } else { $err = "Wrong Username or Password"; } }// end login if statement if ($err) // show error message if there is one { echo $err; echo "<br>Please go back in your browser and try again"; } ?> then index.php <?php session_start(); $loginusername = 'test2';// this is the line that would have to be diferent in every script //it isnt very efficient, i am actually not going to use it but delete it after you have read this. //what we want is a page that does the same for everyone without having to change the code. //so I am going to compare the stored session username against the url to check they match or else it will kick them out //this will however mean literally only the owner can view the page, I hope thats what you are after. $mypath = $_SERVER["REQUEST_URI"]; //echo $mypath; // for debugging //now we have the path lets see if the username is in that path, i.e. test2 is inside /something/test2/index.php //use the built in strpos() function, which returns position of the last occurance of the string you are looking for inside another string. //http://php.net/manual/en/function.strrpos.php if(strpos($mypath,"/".$_SESSION['user']."/"))//on testing it failed initially as username test is found in path /test2/ so i added the slashes to stop that. so /test/ doesnt get found in /test2/ { echo "congratulations you are the right person in the right place"; } else { session_destroy(); //kill the session, naughty person trying to come here header("Location: login.php3"); die();// stop page executing any further } ?> <html> <body> </body> </html>
  20. heya buddy, I am just looking at the files you sent me now, do you however have a copy of the login sucess file, or shall i just make one.
  21. hard to tell without seeing more of the code, but essentially each record should have a unique identifer (primary key). use this to tie the echoed message to that specific id.
  22. if you want to email me the code my address is my forum username @ hotmail.com i'll do it with my morning tea lol which will be later than 7am ner ner
  23. it never knows anything, you have to tell it. lets assume the front end will only display approved items SELECT * FROM table1 WHERE `approved` = 1 on the admin side do the opposite to get the unapproved ones, but if you dont want to build a backend management page, just do it directly in phpmyadmin as you stated
  24. upload the files to the thread, i will take a look, but its gone midnight here, i might well have to do it in the morning. i am happy to upload it and play around with it on your server, but message that information to me if you really want me to.
×
×
  • 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.