NathanS Posted February 16, 2007 Share Posted February 16, 2007 I have been trying for the past day to figure out exactly what is wrong with this document, and it has me completley bewildered - when i submit the below form, i get the following errors: Warning: Missing argument 14 for User::new_user(), called in C:\xampp\htdocs\TopTrumps\register.php on line 106 and defined in C:\xampp\htdocs\TopTrumps\classes.php on line 5 Warning: Missing argument 15 for User::new_user(), called in C:\xampp\htdocs\TopTrumps\register.php on line 106 and defined in C:\xampp\htdocs\TopTrumps\classes.php on line 5 However, here are both register.php and classes.php - I'm completley stuck, and any help at all would be gratefully received! <?php //Let's start the session, so we can include the db.php and classes.php to get the database info! D'uh.. session_start(); require_once("./db.php"); require_once("./classes.php"); include('header.php'); $protect = array( "<" => "<", ">" => ">", "&" => "&", "\"" => """, "'" => "'", "\n" => " ", "\t" => " ", "\r" => " ", "\0" => " ", "\x0B" => "" ); $pattern = "/^[\w-]+(\.[\w-]+)*@"; $pattern .= "([0-9a-z][0-9a-z-]*[0-9a-z]\.)+([a-z]{2,4})$/i"; if ($_POST['submit']) { $r['nick'] = trim(strtr($_POST['nickname'],$protect)); $r['pass'] = trim(strtr($_POST['pass'],$protect)); $r['pass2'] = trim(strtr($_POST['pass2'],$protect)); $r['email'] = trim(strtr($_POST['email'],$protect)); $r['email2'] = trim(strtr($_POST['email2'],$protect)); $r['fname'] = trim(strtr($_POST['fname'],$protect)); $r['gender'] = trim(strtr($_POST['gender'],$protect)); $r['address'] = trim(strtr($_POST['address'],$protect)); $r['city'] = trim(strtr($_POST['city'],$protect)); $r['county'] = trim(strtr($_POST['county'],$protect)); $r['postcode'] = trim(strtr($_POST['postcode'],$protect)); $r['occupation'] = trim(strtr($_POST['occupation'],$protect)); $r['cc'] = trim(strtr($_POST['cc'],$protect)); $r['mileage'] = trim(strtr($_POST['mileage'],$protect)); $r['topspeed'] = trim(strtr($_POST['topspeed'],$protect)); $r['value'] = trim(strtr($_POST['value'],$protect)); $r['brakehorsepower'] = trim(strtr($_POST['brakehorsepower'],$protect)); $r['shows1'] = trim(strtr($_POST['shows1'],$protect)); $err = ""; $u = @mysql_result("select nick from `members` where nick = '".$r['nick']."'"); if ($u) { $err .= "<br />The username you chose has already been taken."; } if (!$r['nick']) { $err .= "<br />Login name was left empty."; } if (strcspn($r['nick'],"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_")) { $err .= "<br />The login name you entered contains invalid characters."; } if ($r['pass'] != $r['pass2']) { $err .= "<br />The entered passwords do not match."; } elseif ((!$r['pass']) or (!$r['pass2'])) { $err .= "<br />You need to choose a password."; } if (!$r['email']) { $err .= "<br />You need to enter your e-mail address."; } elseif ($r['email'] != $r['email2']) { $err .= "<br />The entered e-mail addresses do not match."; } elseif (!preg_match($pattern, $r['email'])) { $err .= "<br />The e-mail address is invalid."; } if (!$r['fname']) { $err .= "<br />You need to enter your full name."; } if (!$r['city']) { $err .= "<br />You need to enter your city."; } if (!$r['county']) { $err .= "<br />You need to enter your county."; } if (!$r['cc']) { $err .= "<br />You need to enter your vehicle's cc."; } if (!$r['mileage']) { $err .= "<br />You need to enter your vehicle's mileage."; } if (!$r['topspeed']) { $err .= "<br />You need to enter your vehicle's top speed."; } if (!$r['value']) { $err .= "<br />You need to enter your vehicle's value."; } if (!$r['brakehorsepower']) { $err .= "<br />You need to enter your vehicle's BHP."; } if (!$r['shows1']) { $err .= "<br />You need to enter shows attended each year."; } if (!$r['address']) { $err .= "<br />You need to enter your address."; } if (!$r['postcode']) { $err .= "<br />You need to enter your postcode."; } } ?> <? if (($_POST['submit']) and (!$err)) { $u = new User; $u->new_user($r['nick'],$r['pass'],$r['email'],$r['fname'],$r['gender'],$r['city'],$r['county'],$r['cc'],$r['mileage'],$r['topspeed'],$r['value'],$r['brakehorsepower'],$r['shows1']); ?> <h3 class="top_main_heading">Welcome to Top Trumps from Herts Insurance!</h3> <p>Congratulations, <?=$r['nick']?> - you have successfully registered for HIC Top Trumps! To continue, login now.</p> <? } else { ?> <!-- What we'll do if you haven't submitted the form... --> <h3 class="top_main_heading">Register for Top Trumps</h3> <div class="box"> <p>You're only a few minutes away from becoming a Top Trumps member. Please fill out the following fields. Those marked with a <span class="star">*</span> <strong>must</strong> be filled out.</p> </div> <form name="signup" method="post" action="register.php"> <? if ($err) { ?> <h3 class="error">Whoops!</h3> <div class="box"> <p> <strong>The following errors occurred:</strong> <?=$err?> <br /><strong>For your safety, the Password fields have been cleared - you need to re-enter your password.</strong> </p> </div> <? } ?> <h3>Your Top Trumps Account</h3> <div class="box"> <table class="signuptable"> <tr> <td class="r">Login Name:</td> <td class="l"><input type="text" name="nickname" size="20" class="input_textbox" value="<?=$r['nick']?>" /> <span class="star">*</span></td> </tr> <tr> <td class="r">Password:</td> <td class="l"><input type="password" name="pass" size="20" class="input_textbox" /> <span class="star">*</span></td> </tr> <tr> <td class="r">Password (again):</td> <td class="l"><input type="password" name="pass2" size="20" class="input_textbox" /> <span class="star">*</span></td> </tr> <tr> <td class="r">E-Mail:</td> <td class="l"><input type="text" name="email" size="20" class="input_textbox" value="<?=$r['email']?>" /> <span class="star">*</span></td> </tr> <tr> <td class="r">E-Mail (again):</td> <td class="l"><input type="text" name="email2" size="20" class="input_textbox" value="<?=$r['email2']?>" /> <span class="star">*</span></td> </tr> </table> </div> <h3>Your Vehicle/Top Trumps Details</h3> <div class="box"> <table class="signuptable"> <tr> <td class="r">Full Name:</td> <td class="l"><input type="text" name="fname" size="20" class="input_textbox" value="<?=$r['fname']?>" /> <span class="star">*</span></td> </tr> <tr> <td class="r">Gender:</td> <td class="l"><input type="radio" name="gender" value="m" <? if ($r['gender'] == "m") { ?>checked="checked" <? } ?>/> Male <input type="radio" name="gender" value="f" <? if ($r['gender'] == "f") { ?>checked="checked" <? } ?>/> Female</td> </tr> <tr> <td class="r">Age:</td> <td class="l"><input type="text" name="age" size="5" class="input_textbox" value="<?=$r['age']?>" /><span class="star">*</span></td> </tr> <tr> <td class="r">First Line Of Address:</td> <td class="l"><input type="text" name="address" size="20" class="input_textbox" value="<?=$r['address']?>" /><span class="star">*</span></td> </tr> <tr> <td class="r">City/State:</td> <td class="l"><input type="text" name="city" size="20" class="input_textbox" value="<?=$r['city']?>" /><span class="star">*</span></td> </tr> <tr> <td class="r">County:</td> <td class="l"><input type="text" name="county" size="20" class="input_textbox" value="<?=$r['county']?>" /><span class="star">*</span></td> </tr> <tr> <td class="r">Postcode:</td> <td class="l"><input type="text" name="postcode" size="20" class="input_textbox" value="<?=$r['postcode']?>" /><span class="star">*</span></td> </tr> <tr> <td class="r">BHP:</td> <td class="l"><input type="text" name="brakehorsepower" size="20" class="input_textbox" value="<?=$r['brakehorsepower']?>" /> <span class="star">*</span></td> </tr> <tr> <td class="r">Shows Attended Last Year:</td> <td class="l"><input type="text" name="shows1" size="20" class="input_textbox" value="<?=$r['shows1']?>" /> <span class="star">*</span></td> </tr> <tr> <td class="r">Vehicle CC:</td> <td class="l"><input type="text" name="cc" size="20" class="input_textbox" value="<?=$r['cc']?>" /><span class="star">*</span></td> </tr> <td class="r">Mileage Reading:</td> <td class="l"><input type="text" name="mileage" size="20" class="input_textbox" value="<?=$r['mileage']?>" /><span class="star">*</span></td> </tr> <td class="r">Top Speed:</td> <td class="l"><input type="text" name="topspeed" size="20" class="input_textbox" value="<?=$r['topspeed']?>" /><span class="star">*</span></td> </tr> <td class="r">Vehicle Value:</td> <td class="l"><input type="text" name="value" size="20" class="input_textbox" value="<?=$r['value']?>" /><span class="star">*</span></td> </tr> </table> </div> <h3>All done?</h3> <div class="box"> <p style="text-align:center;"><input type="submit" name="submit" value="Register" class="input_button" style="font-size:18px; padding:5px;" /></p> </div> </form> <? } ?> <?php include('footer.php') ?> and classes.php ... <?php class User { var $_id, $_nick, $_pass, $_email, $_fname, $_gender, $_address, $_city, $_county, $_picid, $_postcode, $_cc, $_mileage, $_topspeed, $_value, $_brakehorsepower, $_shows1; function new_user($nick, $pass, $email, $fname, $gender, $address, $city, $county, $postcode, $cc, $mileage, $topspeed, $value, $brakehorsepower, $shows1) { mysql_query("INSERT INTO members (nick, pass, email, fname, gender, address, city, county, postcode, cc, mileage, topspeed, value, brakehorsepower, shows1) VALUES ('$nick', '$pass', '$email', '$fname', '$gender', '$address', '$city', '$county', '$postcode', '$cc', '$mileage', '$topspeed', '$value', '$brakehorsepower', '$shows1')") or die (mysql_error()); return true; } function get_user($nick) { $user = @mysql_fetch_array(@mysql_query("select * from members where nick = '$nick'")); $this->_id = $user['id']; $this->_nick = $user['nick']; $this->_pass = $user['pass']; $this->_email = $user['email']; $this->_fname = $user['fname']; $this->_gender = $user['gender']; $this->_age = $user['age']; $this->_address = $user['address']; $this->_city = $user['city']; $this->_county = $user['county']; $this->_picid = $user['picid']; $this->_postcode = $user['postcode']; $this->_cc = $user['cc']; $this->_mileage = $user['mileage']; $this->_topspeed = $user['topspeed']; $this->_value = $user['value']; $this->_brakehorsepower = $user['brakehorsepower']; $this->_shows1 = $user['shows1']; } function save_user() { mysql_query("update members set pass = '".$this->_pass."', email = '".$this->_email."', fname = '".$this->_fname."', gender = '".$this->_gender."', age = ".$this->_age.", address = '".$this->_address."', city = '".$this->_city."', county = '".$this->_county."', picid = '".$this->_picid."', postcode = '".$this->_postcode."', cc = '".$this->_cc."', mileage = '".$this->_mileage."', topspeed = '".$this->_topspeed."', value = '".$this->_value."', brakehorsepower = '".$this->_brakehorsepower."', shows1 = '".$this->_shows."' where id = ".$this->_id); } function login($nick,$pass) { $hashedpass = md5(md5($pass) + "$%#59djc@#"); $user = @mysql_fetch_array(@mysql_query("select * from members where nick = '$nick' and pass = '$pass'")); $storedpass = md5(md5($user['pass']) + "$%#59djc@#"); if ($hashedpass == $storedpass) { $_SESSION['nick'] = $user['nick']; $_SESSION['ident'] = $hashedpass; return true; } else { return false; } } function getpic() { return "./avs/".$this->_picid; } } ?> Link to comment https://forums.phpfreaks.com/topic/38740-stuck-on-register-and-no-clue-as-to-why/ Share on other sites More sharing options...
JasonLewis Posted February 16, 2007 Share Posted February 16, 2007 your missing two arguments, and according to your class your missing address and postcode. in your regsiter you do not have those variables. Link to comment https://forums.phpfreaks.com/topic/38740-stuck-on-register-and-no-clue-as-to-why/#findComment-186146 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.