Jump to content

Muddy_Funster

Members
  • Posts

    3,372
  • Joined

  • Last visited

  • Days Won

    18

Everything posted by Muddy_Funster

  1. you never close you if statment. you are missing a } out so the code is running out before it is properly terminated.
  2. do you get anything back if you do a var_dump($_POST); ?
  3. depends on how you are populating your select element, which without code I can't see
  4. check the value as it's being rendered and if it's the matching one from the previous submition add the selected="selected" to the option.
  5. then you need to use the same technique when assigning errors. I don't even know if your photo upload is the same class as the register user one, I don't know what format you have used to define the errors property of the class, in short, other than what you show me, I don't know your code. Without seeing the whole class I can't help.
  6. am I right to assume that the first page you posted is in the same directory as the form page and is called datesd.php (case sensitive accuracy)?
  7. am I right in thinking that your are pretty new to OOP? Anyway, the only thing that's really going to help is to see the full class that youe are using.
  8. the is_array and is_object are there to check on the datatype that is returned, so you can react accordingly. to pass it into the the errors method, rather than making the errors array in the Reg method, simply point the message to your existing errors method using $this->errors("You forgot to enter yuopr user name"); I'm making a few assumptions here as you havn't posted anything about an errors method or any other part of your class outside the Reg method.
  9. could you post up your form code aswell please?
  10. ok, take a look at the difference here : public static function Reg($first_name, $last_name) { if(!empty($first_name) && !empty($last_name)) { $register = new User(); $register->first_name = $first_name; $register->last_name = $last_name; return $register; } else{ if(empty($first_name)){ $errors[] = 'You forgot to enter your username.'; } if(empty($last_name)){ $errors[] = 'You forgot to enter your lastname.'; } return $errors; } } //------------------------------------------------------------------------------ //############################################################################## //------------------------------------------------------------------------------ if(isset($_POST['submit'])) { $first_name = trim($_POST['first_name']); $last_name = trim($_POST['last_name']); $new_user = User::Reg($first_name, $last_name); if(!is_array($new_user) && is_object($new_user) && $new_user->save()) { // comment saved // No message needed; seeing the comment is proof enough. // Important! You could just let the page render from here. // But then if the page is reloaded, the form will try // to resubmit the comment. So redirect instead: redirect_to("photo.php?id={$photo->id}"); } elseif(!is_object($new_user) && is_array($new_user)) { // Failed foreach($new_user as $errorMessage){ echo $errorMessage."<br />"; } } else { $first_name = ""; $last_name = ""; } Edt : added } to code
  11. you're still returning false, you need to return the errors array, then change your logic on the main script to check what is returned, probably using is_array() and is_object() to see if it's the errors that are returned or the $register object
  12. file extension doesn't matter for includes/requires
  13. Within the Reg method you would need to either change your else to a couple of elseif 's or add another if inside the the else to check whcih of the fields was ommited and return an appropriate response deppending on which field(s) are left out.
  14. you're thinking is fine, you don't need js for this.
  15. anther thing you could look into would be to use $_SESSION variables, rather than URL variables, to pass the information about between pages in a way that is not imediately visible to the end user. But as requinix said, you must validate the user before allowing them to make changes to anything, regardless of which way you do it.
  16. I personaly can not recomend any up-to-date books on PHP, been a while since I had much time for reading php. If you start a new thread about it though I'm sure there will be severall suggestions, both for books and for projects.
  17. why have you commented out the lines at the top of the invintory page - including the session_start()? You should check if the $_SESSION['id'] is actualy set rather than checking if the $user != 0 by using if(!isset($_SESSION['id'])){ echo "You're not logged in"; } Why? What help do you see that will that be to the current problem?Aslo, as a general rule of thumb - You shoudn't give instruction without validating your statement.
  18. Try working through these : http://www.tizag.com/ajaxTutorial/
  19. what do you meen make it? what exactly are you having an issue with? let's see what code you have already.
  20. could you please edit you post to use code tags around your script? That's rather hard to read like that.
  21. your text filed is missing a bunch of attributes, so is your form. try this: <form name="townFilter" id="townFilter" method="post" action="viewall.php"> Town <input type="text" name="townInput" value="" /> <input type="submit" name="townsearch" value="Search" /> </form> This will let you access the $_POST superglobal array when you get to the viewall.php page. superglobal arrays are special arrays in PHP, the main ones are $_POST, $_GET, $_SERVER and $_SESSION $_POST and $_GET deal with form data (and url data in the case of $_GET) and are key to interacting with users through forms. to access the arrays you need to do several things, set the method that the form uses to send the data using method="post" / method="get" name the form elements (you should really be doing this anyway as a best-practice) set up some code on the target .php page to check for and use the form data when it gets there. read up on $_POST at the php.net/manual site
  22. see how you get on with this : http://www.tizag.com/mysqlTutorial/mysqlwhere.php
  23. why must the gc number be random? what format is the gc number field? int/varchar?
×
×
  • 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.