-
Posts
3,372 -
Joined
-
Last visited
-
Days Won
18
Everything posted by Muddy_Funster
-
After Submiting, Formtoemail.php Return Error At Php Closure(?>)
Muddy_Funster replied to PrPrO's topic in PHP Coding Help
you never close you if statment. you are missing a } out so the code is running out before it is properly terminated. -
Php Code Not Working After Hosting Transfer
Muddy_Funster replied to mdeppa's topic in PHP Coding Help
do you get anything back if you do a var_dump($_POST); ? -
depends on how you are populating your select element, which without code I can't see
-
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.
-
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.
-
Php Code Not Working After Hosting Transfer
Muddy_Funster replied to mdeppa's topic in PHP Coding Help
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)? -
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.
-
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.
-
Php Code Not Working After Hosting Transfer
Muddy_Funster replied to mdeppa's topic in PHP Coding Help
could you post up your form code aswell please? -
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
-
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
-
file extension doesn't matter for includes/requires
-
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.
-
you're thinking is fine, you don't need js for this.
-
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.
-
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.
-
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.
-
yeah, I expect you would.
-
what do you meen make it? what exactly are you having an issue with? let's see what code you have already.
-
Triple Drop Down In Php Using Ajax And Javascript!
Muddy_Funster replied to saravanataee's topic in PHP Coding Help
could you please edit you post to use code tags around your script? That's rather hard to read like that. -
Return Results From A Mysql Database Dependent On Town Entered
Muddy_Funster replied to ianhaney's topic in PHP Coding Help
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 -
Return Results From A Mysql Database Dependent On Town Entered
Muddy_Funster replied to ianhaney's topic in PHP Coding Help
see how you get on with this : http://www.tizag.com/mysqlTutorial/mysqlwhere.php -
Help With Inserting To Sql From Php
Muddy_Funster replied to darrenwindle's topic in PHP Coding Help
and why random? -
Help With Inserting To Sql From Php
Muddy_Funster replied to darrenwindle's topic in PHP Coding Help
why must the gc number be random? what format is the gc number field? int/varchar?