jamesxg1 Posted August 3, 2009 Share Posted August 3, 2009 Hiya peeps, i have this code. <?php include 'includes/commands.inc'; $add = new Command(); $add->MYSQLConnection(); exit(print_r($_POST)); if(isset($_POST['register'])) { $add->AddMem($_POST['firstname'], $_POST['lastname'], $_POST['username'], $_POST['password'], $_POST['email'], $_POST['phone'], $_POST['address'], $_POST['addresstwo'], $_POST['city'], $_POST['county'], $_POST['postcode'], $_POST['country']); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Register</title> <link rel="stylesheet" type="text/css" href="core/css/view.css" media="all"> <script type="text/javascript" src="core/js/view.js"></script> </head> <body id="main_body" > <img id="top" src="top.png" alt=""> <div id="form_container"> <h1><a></a></h1> <form id="register" class="appnitro" method="post" action=""> <div class="form_description"> <h2>Untitled Form</h2> <p>This is your form description. Click here to edit.</p> </div> <ul > <li id="li_1" > <label class="description" for="element_1">Name: </label> <span> <input id="firstname" name= "firstname" class="element text" maxlength="255" size="8" value=""/> <label>First</label> </span> <span> <input id="lastname" name= "lastname" class="element text" maxlength="255" size="14" value=""/> <label>Last</label> </span><p class="guidelines" id="guide_1"><small>Please enter your full name.</small></p> </li> <li id="li_2" > <label class="description" for="element_2">Username: </label> <div> <input id="username" name="username" class="element text medium" type="text" maxlength="255" value=""/> </div><p class="guidelines" id="guide_2"><small>Please enter a Username.</small></p> </li> <li id="li_3" > <label class="description" for="element_3">Password: </label> <div> <input id="password" name="password" class="element text medium" type="password" maxlength="255" value=""/> </div><p class="guidelines" id="guide_3"><small>Please enter a desiered password.</small></p> </li> <li id="li_3" > <label class="description" for="element_3">Email Address: </label> <div> <input id="email" name="email" class="element text medium" type="text" maxlength="255" value="@"/> </div><p class="guidelines" id="guide_3"><small>Your email address must go here.</small></p> </li> <li id="li_4" > <label class="description" for="element_4">Phone Number: </label> <div> <input id="phone" name="phone" class="element text medium" type="text" maxlength="255" value=""/> </div><p class="guidelines" id="guide_4"><small>Your phone number must go here.</small></p> </li> <li id="li_5" > <label class="description" for="element_5">Address:</label> <div> <input id="address" name="address" class="element text large" value="" type="text"> <label for="element_5_1">Street Address</label> </div> <div> <input id="addresstwo" name="addresstwo" class="element text large" value="" type="text"> <label for="element_5_2">Address Line 2</label> </div> <div class="left"> <input id="city" name="city" class="element text medium" value="" type="text"> <label for="element_5_3">City</label> </div> <div class="right"> <select class="element text medium" id="county" name="county"> <?php $resultt = mysql_query("SELECT * FROM `counties`") or die(mysql_error()); while($roww = mysql_fetch_assoc($resultt)) { $dropdownn .= "<option value=" . $roww['county'] . ">" .$roww['county'] . "</option>"; } echo $dropdownn; ?> </select> <label for="element_5_4">County</label> </div> <div class="left"> <input id="postcode" name="postcode" class="element text medium" maxlength="15" value="" type="text"> <label for="element_5_5">Postcode</label> </div> <div class="right"> <select class="element select medium" id="country" name="country"> <option value="Afghanistan" >Afghanistan</option> <option value="Albania" >Albania</option> <option value="Algeria" >Algeria</option> <option value="Andorra" >Andorra</option> <option value="Antigua and Barbuda" >Antigua and Barbuda</option> <option value="Argentina" >Argentina</option> <option value="Armenia" >Armenia</option> <option value="Australia" >Australia</option> <option value="Austria" >Austria</option> <option value="Azerbaijan" >Azerbaijan</option> <option value="Bahamas" >Bahamas</option> <option value="Bahrain" >Bahrain</option> <option value="Bangladesh" >Bangladesh</option> <option value="Barbados" >Barbados</option> <option value="Belarus" >Belarus</option> <option value="Belgium" >Belgium</option> <option value="Belize" >Belize</option> <option value="Benin" >Benin</option> <option value="Bhutan" >Bhutan</option> <option value="Bolivia" >Bolivia</option> <option value="Bosnia and Herzegovina" >Bosnia and Herzegovina</option> <option value="Botswana" >Botswana</option> <option value="Brazil" >Brazil</option> <option value="Brunei" >Brunei</option> <option value="Bulgaria" >Bulgaria</option> <option value="Burkina Faso" >Burkina Faso</option> <option value="Burundi" >Burundi</option> <option value="Cambodia" >Cambodia</option> <option value="Cameroon" >Cameroon</option> <option value="Canada" >Canada</option> <option value="Cape Verde" >Cape Verde</option> <option value="Central African Republic" >Central African Republic</option> <option value="Chad" >Chad</option> <option value="Chile" >Chile</option> <option value="China" >China</option> <option value="Colombia" >Colombia</option> <option value="Comoros" >Comoros</option> <option value="Congo" >Congo</option> <option value="Costa Rica" >Costa Rica</option> <option value="Côte d'Ivoire" >Côte d'Ivoire</option> <option value="Croatia" >Croatia</option> <option value="Cuba" >Cuba</option> <option value="Cyprus" >Cyprus</option> <option value="Czech Republic" >Czech Republic</option> <option value="Denmark" >Denmark</option> <option value="Djibouti" >Djibouti</option> <option value="Dominica" >Dominica</option> <option value="Dominican Republic" >Dominican Republic</option> <option value="East Timor" >East Timor</option> <option value="Ecuador" >Ecuador</option> <option value="Egypt" >Egypt</option> <option value="El Salvador" >El Salvador</option> <option value="Equatorial Guinea" >Equatorial Guinea</option> <option value="Eritrea" >Eritrea</option> <option value="Estonia" >Estonia</option> <option value="Ethiopia" >Ethiopia</option> <option value="Fiji" >Fiji</option> <option value="Finland" >Finland</option> <option value="France" >France</option> <option value="Gabon" >Gabon</option> <option value="Gambia" >Gambia</option> <option value="Georgia" >Georgia</option> <option value="Germany" >Germany</option> <option value="Ghana" >Ghana</option> <option value="Greece" >Greece</option> <option value="Grenada" >Grenada</option> <option value="Guatemala" >Guatemala</option> <option value="Guinea" >Guinea</option> <option value="Guinea-Bissau" >Guinea-Bissau</option> <option value="Guyana" >Guyana</option> <option value="Haiti" >Haiti</option> <option value="Honduras" >Honduras</option> <option value="Hong Kong" >Hong Kong</option> <option value="Hungary" >Hungary</option> <option value="Iceland" >Iceland</option> <option value="India" >India</option> <option value="Indonesia" >Indonesia</option> <option value="Iran" >Iran</option> <option value="Iraq" >Iraq</option> <option value="Ireland" >Ireland</option> <option value="Israel" >Israel</option> <option value="Italy" >Italy</option> <option value="Jamaica" >Jamaica</option> <option value="Japan" >Japan</option> <option value="Jordan" >Jordan</option> <option value="Kazakhstan" >Kazakhstan</option> <option value="Kenya" >Kenya</option> <option value="Kiribati" >Kiribati</option> <option value="North Korea" >North Korea</option> <option value="South Korea" >South Korea</option> <option value="Kuwait" >Kuwait</option> <option value="Kyrgyzstan" >Kyrgyzstan</option> <option value="Laos" >Laos</option> <option value="Latvia" >Latvia</option> <option value="Lebanon" >Lebanon</option> <option value="Lesotho" >Lesotho</option> <option value="Liberia" >Liberia</option> <option value="Libya" >Libya</option> <option value="Liechtenstein" >Liechtenstein</option> <option value="Lithuania" >Lithuania</option> <option value="Luxembourg" >Luxembourg</option> <option value="Macedonia" >Macedonia</option> <option value="Madagascar" >Madagascar</option> <option value="Malawi" >Malawi</option> <option value="Malaysia" >Malaysia</option> <option value="Maldives" >Maldives</option> <option value="Mali" >Mali</option> <option value="Malta" >Malta</option> <option value="Marshall Islands" >Marshall Islands</option> <option value="Mauritania" >Mauritania</option> <option value="Mauritius" >Mauritius</option> <option value="Mexico" >Mexico</option> <option value="Micronesia" >Micronesia</option> <option value="Moldova" >Moldova</option> <option value="Monaco" >Monaco</option> <option value="Mongolia" >Mongolia</option> <option value="Montenegro" >Montenegro</option> <option value="Morocco" >Morocco</option> <option value="Mozambique" >Mozambique</option> <option value="Myanmar" >Myanmar</option> <option value="Namibia" >Namibia</option> <option value="Nauru" >Nauru</option> <option value="Nepal" >Nepal</option> <option value="Netherlands" >Netherlands</option> <option value="New Zealand" >New Zealand</option> <option value="Nicaragua" >Nicaragua</option> <option value="Niger" >Niger</option> <option value="Nigeria" >Nigeria</option> <option value="Norway" >Norway</option> <option value="Oman" >Oman</option> <option value="Pakistan" >Pakistan</option> <option value="Palau" >Palau</option> <option value="Panama" >Panama</option> <option value="Papua New Guinea" >Papua New Guinea</option> <option value="Paraguay" >Paraguay</option> <option value="Peru" >Peru</option> <option value="Philippines" >Philippines</option> <option value="Poland" >Poland</option> <option value="Portugal" >Portugal</option> <option value="Puerto Rico" >Puerto Rico</option> <option value="Qatar" >Qatar</option> <option value="Romania" >Romania</option> <option value="Russia" >Russia</option> <option value="Rwanda" >Rwanda</option> <option value="Saint Kitts and Nevis" >Saint Kitts and Nevis</option> <option value="Saint Lucia" >Saint Lucia</option> <option value="Saint Vincent and the Grenadines" >Saint Vincent and the Grenadines</option> <option value="Samoa" >Samoa</option> <option value="San Marino" >San Marino</option> <option value="Sao Tome and Principe" >Sao Tome and Principe</option> <option value="Saudi Arabia" >Saudi Arabia</option> <option value="Senegal" >Senegal</option> <option value="Serbia and Montenegro" >Serbia and Montenegro</option> <option value="Seychelles" >Seychelles</option> <option value="Sierra Leone" >Sierra Leone</option> <option value="Singapore" >Singapore</option> <option value="Slovakia" >Slovakia</option> <option value="Slovenia" >Slovenia</option> <option value="Solomon Islands" >Solomon Islands</option> <option value="Somalia" >Somalia</option> <option value="South Africa" >South Africa</option> <option value="Spain" >Spain</option> <option value="Sri Lanka" >Sri Lanka</option> <option value="Sudan" >Sudan</option> <option value="Suriname" >Suriname</option> <option value="Swaziland" >Swaziland</option> <option value="Sweden" >Sweden</option> <option value="Switzerland" >Switzerland</option> <option value="Syria" >Syria</option> <option value="Taiwan" >Taiwan</option> <option value="Tajikistan" >Tajikistan</option> <option value="Tanzania" >Tanzania</option> <option value="Thailand" >Thailand</option> <option value="Togo" >Togo</option> <option value="Tonga" >Tonga</option> <option value="Trinidad and Tobago" >Trinidad and Tobago</option> <option value="Tunisia" >Tunisia</option> <option value="Turkey" >Turkey</option> <option value="Turkmenistan" >Turkmenistan</option> <option value="Tuvalu" >Tuvalu</option> <option value="Uganda" >Uganda</option> <option value="Ukraine" >Ukraine</option> <option value="United Arab Emirates" >United Arab Emirates</option> <option value="United Kingdom" >United Kingdom</option> <option value="United States" >United States</option> <option value="Uruguay" >Uruguay</option> <option value="Uzbekistan" >Uzbekistan</option> <option value="Vanuatu" >Vanuatu</option> <option value="Vatican City" >Vatican City</option> <option value="Venezuela" >Venezuela</option> <option value="Vietnam" >Vietnam</option> <option value="Yemen" >Yemen</option> <option value="Zambia" >Zambia</option> <option value="Zimbabwe" >Zimbabwe</option> </select> <label for="element_7_6">Country</label> </div><p class="guidelines" id="guide_7"><small>Please enter a vaild address.</small></p> </li> <li class="buttons"> <input id="register" class="button_text" type="submit" name="register" value="Submit" /> </li> </ul> </form> <div id="footer"> </div> </div> <img id="bottom" src="bottom.png" alt=""> </body> </html> Because it wasn't working i put a exit() at the top and this is all i got. Array ( [firstname] => dfg [lastname] => gdf [username] => gdfg [password] => dfgdfg [email] => @dfgdfg [phone] => dfgdf [address] => dfgdfg [addresstwo] => fdgdf [city] => gdfg [county] => Aberdeen [postcode] => dfgdfg [country] => Afghanistan [register] => Submit ) 1 Thats all correct except i have the number '1' at the end, what for ? Many thanks, James. Quote Link to comment https://forums.phpfreaks.com/topic/168666-solved-form-array-help/ Share on other sites More sharing options...
jamesxg1 Posted August 3, 2009 Author Share Posted August 3, 2009 Sorry this is the included file. <?php class Command { private $dbusername; private $dbpassword; private $dbhost; private $dbbase; private $lusername; private $lpassword; private $randid; private $aname; private $aadress; private $aadresstwo; private $apostcode; private $acountry; private $aphone; private $acounty; private $mfirstname; private $mlastname; private $musername; private $mpassword; private $memail; private $mphone; private $mtype; private $maddress; private $maddresstwo; private $mcity; private $mcounty; private $mpostcode; private $mcountry; private $sesid; private $sesuser; private $estid; private $tempuser; private $temppass; function __construct($dbusername = "root", $dbpassword = "", $dbhost = "localhost", $dbbase = "sli", $lusername = "none", $lpassword = "none", $randid = "mt_rand();", $aname = "none", $aaddress = "none", $aaddresstwo = "none", $apostocde = "none", $acountry = "none", $aphone = "none", $acounty = "none", $tempuser = "mt_rand();", $temppass = "mt_rand();") { $this->dbusername = $dbusername; $this->dbpassword = $dbpassword; $this->dbhost = $dbhost; $this->dbbase = $dbbase; $this->lusername = $lusername; $this->lpassowrd = $lpassword; $this->randid = mt_rand(); $this->tempuser = $tempuser; $this->temppass = $temppass; } function MYSQLConnection() { $this->MYSQLConnect = mysql_connect($this->dbhost, $this->dbusername, $this->dbpassword); $this->SelectDB = mysql_select_db($this->dbbase, $this->MYSQLConnect) or die(mysql_error()); return($this->SelectDB); } function Login($lusername, $lpassword) { session_start(); $this->lusername = mysql_real_escape_string($lusername); $this->lpassword = mysql_real_escape_string(md5($lpassword)); $this->LoginQ = "SELECT * FROM `members` WHERE username = '$this->lusername' AND password = '$this->lpassword'"; $this->LoginR = mysql_query($this->LoginQ) or die (mysql_error()); if(mysql_num_rows($this->LoginR) == '1') { while($fetch = mysql_fetch_array($this->LoginR)) { if($fetch['sus'] == '0') { $_SESSION['username'] = $this->lusername; $_SESSION['id'] = $fetch['id']; $_SESSION['firstname'] = $fetch['firstname']; $this->lid = $fetch['id']; header('Location: user_home.php'); } else { echo ("Sorry but the account you are trying to access is suspended, Please try again."); exit(); } } echo "Sorry but the account you are trying to access is non existant, Please try again."; } } function Logout() { session_start(); session_unset(); session_destroy(); header('Location: login.php'); } function AddEst($aname, $aaddress, $aaddresstwo, $apostcode, $acountry, $aphone, $acounty) { $this->aname = $aname; $this->aaddress = $aaddress; $this->aaddresstwo = $aaddresstwo; $this->apostcode = $apostcode; $this->acountry = $acountry; $this->aphone = $aphone; $this->acounty = $acounty; $this->randid = mt_rand(); $this->aeusername = $_SESSION['username']; $this->aeid = $_SESSION['id']; mysql_query("INSERT INTO `establishments` (mid, username, id, name, address, addresstwo, postcode, county, phone, country) VALUES('$this->aeid', '$this->aeusername', '$this->randid', '$this->aname', '$this->aaddress', '$this->aaddresstwo', '$this->apostcode', '$this->acounty', '$this->aphone', '$this->acountry')") or die(mysql_error()); $adddone = "Your establishment was succesfully added."; return $adddone; } function SessionSecurity() { if (!function_exists('session_regenerate_id')) { $tv = gettimeofday(); $lcg['s1'] = $tv['sec'] ^ (~$tv['usec']); $lcg['s2'] = posix_getpid(); $q = (int) ($lcg['s1'] / 53668); $lcg['s1'] = (int) (40014 * ($lcg['s1'] - 53668 * $q) - 12211 * $q); if ($lcg['s1'] < 0) $lcg['s1'] += 2147483563; $q = (int) ($lcg['s2'] / 52774); $lcg['s2'] = (int) (40692 * ($lcg['s2'] - 52774 * $q) - 3791 * $q); if ($lcg['s2'] < 0) $lcg['s2'] += 2147483399; $z = (int) ($lcg['s1'] - $lcg['s2']); if ($z < 1) { $z += 2147483562; } return $z * 4.656613e-10; } } function SessionRegen() { $tv = gettimeofday(); $buf = sprintf("%.15s%ld%ld%0.8f", $_SERVER['REMOTE_ADDR'], $tv['sec'], $tv['usec'], $this->SessionSecurity() * 10); session_id(md5($buf)); setcookie('PHPSESSID', session_id(), NULL, '/'); return TRUE; } function SessionCheck() { if(isset($_SESSION['id']) && isset($_SESSION['username']) && isset($_SESSION['firstname'])) { } else { header('Location: login.php'); exit(); } } function AddMem($mfirstname, $mlastname, $musername, $mpassword, $memail, $mphone, $mtype, $maddress, $maddresstwo, $mcity, $mcounty, $mpostcode, $mcountry) { $this->mfirstname = $mfirstname; $this->mlastname = $mlastname; $this->musername = $musername; $this->mpassword = md5($mpassword); $this->memail = $memail; $this->mphone = $mphone; $this->mtype = $mtype; $this->maddress = $maddress; $this->maddresstwo = $maddresstwo; $this->mcity = $mcity; $this->mcounty = $mcounty; $this->mpostcode = $mpostcode; $this->mcountry = $mcountry; mysql_query("INSERT INTO `members` (id, firstname, lastname, email, phone, type, address, addresstwo, city, county, postcode, country, username, password, sus) VALUES('$this->randid', '$this->mfirstname', '$this->mlastname', '$this->memail', '$this->mphone', '$this->mtype', '$this->maddress', '$this->maddresstwo', '$this->mcity', '$this->mcounty', '$this->mpostcode', '$this->mcountry', '$this->musername', '$this->mpassword', '1')") or die(mysql_error()); header('Location: reg_done.html'); } function DelEst($estid) { $this->sesid = $_SESSION['id']; $this->sesuser = $_SESSION['username']; $this->estid = $estid; mysql_query("DELETE FROM `establishments` WHERE mid = '$this->sesid' AND username = '$this->sesuser' AND id = '$this->estid' LIMIT 1") or die(mysql_error()); $deldone = "The establishment you selected was succesfully delete from our database."; return $deldone; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/168666-solved-form-array-help/#findComment-889756 Share on other sites More sharing options...
WolfRage Posted August 3, 2009 Share Posted August 3, 2009 You put the print_r() inside of exit. Data was returned by the print_r() thus exit() is a function that will return FALSE which is the same as 0 or TRUE which is the same as 1. So instead do the print_r() before the exit(), and do not put any code inside the exit() function. Quote Link to comment https://forums.phpfreaks.com/topic/168666-solved-form-array-help/#findComment-889760 Share on other sites More sharing options...
jamesxg1 Posted August 3, 2009 Author Share Posted August 3, 2009 You put the print_r() inside of exit. Data was returned by the print_r() thus exit() is a function that will return FALSE which is the same as 0 or TRUE which is the same as 1. So instead do the print_r() before the exit(), and do not put any code inside the exit() function. Ok. Removed got this. Array ( [firstname] => dfg [lastname] => gdf [username] => gdfg [password] => dfgdfg [email] => @dfgdfg [phone] => dfgdf [address] => dfgdfg [addresstwo] => fdgdf [city] => gdfg [county] => Aberdeen [postcode] => dfgdfg [country] => Afghanistan [register] => Submit ) Warning: Missing argument 13 for Command::AddMem(), called in C:\xampp\htdocs\project\register.php on line 12 and defined in C:\xampp\htdocs\project\includes\commands.inc on line 168 Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\project\register.php: in C:\xampp\htdocs\project\includes\commands.inc on line 186 Quote Link to comment https://forums.phpfreaks.com/topic/168666-solved-form-array-help/#findComment-889763 Share on other sites More sharing options...
WolfRage Posted August 3, 2009 Share Posted August 3, 2009 You are missing $mtype which is an expected variable with in the method AddMem(). It is the 7th variable out of 13 expected for that function. Edit: To avoid the headers error, you need to remove your print_r() statement. Quote Link to comment https://forums.phpfreaks.com/topic/168666-solved-form-array-help/#findComment-889772 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.