Jump to content

IlaminiAyebatonyeDagogo

Members
  • Posts

    64
  • Joined

  • Last visited

Everything posted by IlaminiAyebatonyeDagogo

  1. Am Creating a login Script and i do not want users to put in number or alpha numeric characters in the username field and i use the the ctype_alnum function the problem is that the validation is also affecting the password field below is login script. <div id="login"> <?php if(isset($_POST["login"])&&(empty($_POST["username"])||empty($_POST["password"]))) { echo"<p class='style1' style='background:yellow;' > Please You Have to Provide a Valid Username and password</p>"; $staff=false;}?> <form action="<?php $_SERVER["PHP_SELF"] ?>" method="post"> <label style="font-style:bold;color:#FF9900;" ><h2>UserName:</h2> </label> <?php if(isset($_POST["login"])&&(empty($_POST["username"]))) { echo"Your User Name is Required";$staff=false; } elseif(ctype_alnum($_POST["username"])==true) { echo"You are allowed to put in Numbers<br>"; $staff=false; } ?> <input size="40" type="text" name="username" placeholder="UserName"/><br><br> <label style="font-style:bold;color:#FF9900;" ><h2>Password:</h2> </label> <?php if(isset($_POST["login"])&&(empty($_POST["password"]))) { echo"Your Password is Required";$staff=false; } ?> <input style="radius:6;" size="40" type="password" placeholder="Password" name="password"/><br></div> <input type="submit" width="25px" value="Login" name="login"/> </form> so please help check the code for errors and how to limit the ctype_alnum validation to just the username field.
  2. how to update a database field considering a specific amount of values. the code i Know is this is to update a specific value UPDATE `users` SET `user_level`=1 WHERE `user_id`=7 and this is to update a particular field UPDATE `users` SET `user_level`=1; but the code for a range of values in a field using the id as the range say where id=7 to 35, i don't know the code
  3. Please Dont Be Offended You Got with your Previous Code Thanks Alot
  4. Got this error Warning: Constants may only evaluate to scalar values in /home/skulsolu/public_html/main/jamb/chatfiles/setachat.php on line 29
  5. this is the output stdClass Object ( [user] => stdClass Object ( [id] => 10 [username] => gospel4me [password] => 82c8bdde79b755f81:0832f5422e5a4d4 [email] => gospel@ymail.com [phone] => 804990498 [address] => [pin_id] => 7200 [segment] => jamb [date_created] => 2013-11-18 06:03:05 ) )
  6. got this error Fatal error: Cannot use object of type stdClass as array in /home/skulsolu/public_html/main/jamb/chatfiles/setachat.php on line 29
  7. I have a script that is not own Originally this written in PHP5 and a little in getting the session value am going to write paste all login.php <?php session_start(); $error_page = "index.php?error="; $success_page = "../main/log.php"; define("PPDIA_APP", 1); require_once "../models/db.php"; require_once "../models/loginModel.php"; require_once "../models/sessionModel.php"; //Create a new instance of the loginHandler $login = new loginModel(); $login->setDebug(); $login->setCredentials($_POST['username'], $_POST['card_pin']); //Authenticate user $logged_in = $login->authenticateUser(); if( $logged_in ) { sessionModel::init(); sessionModel::setParam("user", $login->getDetails()); $location = $success_page; } else { $error_page .= "Your username and pin combination is invalid"; $location = $error_page; } exit(); header("Location: {$location}#!/page_jamb utme"); ?> Next is sessionModel.php <?php class sessionModel { public static $session_id = "9jsschoo_php_app"; public static function init() { session_start(); $_SESSION[sessionModel::$session_id] = new stdClass(); } public static function setParam($param, $data) { $_SESSION[sessionModel::$session_id]->$param = $data; } public static function resetParam($param) { unset( $_SESSION[sessionModel::$session_id]->$param ); } public static function getParam($param) { return $_SESSION[sessionModel::$session_id]->$param; } } Next is loginModel.php <?php class loginModel extends db { private $credentials; private $enc_pass; private $details; function loginModel() { parent::__construct(); $credentials = new stdClass(); } function setCredentials($username, $password) { $this->credentials->username = $username; $this->credentials->password = $password; $this->enc_pass = $this->encryptPass($password); } function authenticateUser() { $check = $this->fetchData("", "#__users", "username", $this->credentials->username, "password", $this->enc_pass); if( !empty($check) ) { $this->details = (object) $check[0]; return true; } else { return false; } } function getDetails() { return $this->details; } } This Last One Is Not Important db.php <?php //No direct Access defined("PPDIA_APP") or die("Restricted Access"); class db { private $ppdia_conn, $db_res, $md_pass, $db_name; private $table_prefix, $limit; function db() { $this->table_prefix = ""; $this->ppdia_conn = new mysqli( "localhost", "root", "", "skul_solution" ) or die ( "error" ); } function setPrefix($pref) { $this->table_prefix = $pref; } function getResult() { return $this->ppdia_conn; } function setDebug() { $this->debug = true; } function getDebug( $input ) { if( $this->debug ) { print "<div style='background-color: white; color: red;'><hr />"; if( is_array($input) || is_object($input) ) print "<pre>" . print_r( $input, 1 ) . "</pre>"; else print $input; print "<hr /></div>"; } } function myarray( $array ) { print "<pre>"; print_r( $array); print "</pre>"; } function prepareInput( $input ) { if( is_array( $input ) && !empty( $input ) ) { $keys = array_keys( $input ); foreach( $input as $i ) { $k = $keys[$x]; $prepared = $prepared = $this->prepareString($i); $input[$k] = $prepared; $x++; } } else if( is_string( $input ) ) { $input = $this->prepareString($input); } return $input; } function prepareString($string) { $prepared = $this->ppdia_conn->real_escape_string( stripslashes($string) ); return $prepared; } function encryptPass( $pass ) { $spice = 'p0pSyPeD1A_5p1cypa55'; $site_name = "9jaschool_php"; $hash = md5( "Password: " . $pass . $site_name . $spice ); $mdpass = substr( $hash, 0, 17 ) . ":" . substr( $hash, 17, 33 ); //echo $mdpass; $this->getDebug( "<p>" . $mdpass . "</p>" ); /* * For PHP >= 5.5.0 * $mdpass = apps::encryptString($pass); */ //echo $pass . " is " . $mdpass; return $mdpass; } function insertInto( $table, $rows, $values ) { $table = $this->getTable($table); if( is_string($rows) ) $rows = explode( ",", $rows ); if( is_string($values) ) $values = explode( ",", $values ); if( is_array($values) && is_array($rows) && !empty( $values ) ) { $x = 0; $c = count($values); foreach( $values as $v ) { $r = $rows[$x]; if( $v && $r ) $nuval_arr[] = "`". $r . "`='" . $this->prepareString($v) . "' "; else $nuval_arr[] = "`". $r . "`='' "; $x++; } $val = implode(", ", $nuval_arr); } $value_set = $val; $sql_query = "INSERT INTO `" . $table . "` SET " . $value_set; $cm = $this->ppdia_conn; $this->getDebug( $sql_query ); //Insert the data into the database.... $queried = $cm->query( $sql_query ); if( $queried ) { $this->getDebug($cm->insert_id); return $cm->insert_id; } else { return false; } } function updateData( $type='string', $tab_name, $row, $data, $key1='', $value1='', $key2=NULL, $value2=NULL, $no_queries=5, $switch=1 ) { $tab_name = $this->getTable($tab_name); $cm = $this->ppdia_conn; if ( $type=='string' ) { if( !$key2 ) $reg_q = "UPDATE `" . $tab_name. "` SET `" . $row . "` = '" . $data . "' WHERE `" . $key1 . "` = '" . $value1 . "';"; else $reg_q = "UPDATE `" . $tab_name. "` SET `" . $row . "` = '" . $data . "' WHERE `" . $key1 . "` = '" . $value1 . "' AND `" . $key2 . "` = '" . $value2 . "';"; } else { foreach( $row as $ro ) $db_row[] = $ro; foreach( $data as $d ) $udata[] = $d; //print "<pre>"; print_r($udata); print"</pre>"; $x = 0; foreach( $db_row as $key=>$r ) { $sets[] = "`" . $r . "` = '" . $udata[$x] . "'"; $x++; } if( !$key2 ) $where = "WHERE `" . $key1 . "` = '" . $value1 . "';"; else $where = "WHERE `" . $key1 . "` = '" . $value1 . "' AND `" . $key2 . "` = '" . $value2 . "';"; $reg_q = "UPDATE `" . $tab_name. "` SET " . implode(", ", $sets) . " " . $where; } $this->getDebug($reg_q); $reg = $cm->query( $reg_q ); $res = $reg->affected_rows; return $res; } function checkDb() { if ( !$this->ppdia_conn ) return "Could Not Connect to The Database"; else return true; } function getType($data) { if( !is_numeric($data) ) $data = "'" . $data . "'"; return $data; } function getTable($tname) { return str_replace( "#__", $this->table_prefix, $tname ); } function getTableCols($table) { $table_name = $this->getTable($table); $sql = "SELECT table_name, column_name, data_type, data_length FROM USER_TAB_COLUMNS WHERE table_name = '" . $table_name . "';"; //Mysql specific.. $sql = "SHOW FIELDS FROM `" . $table_name . "`;"; return $this->customQuery($sql); } function setLimit($start, $length) { $this->limit = " LIMIT {$start}, {$length} "; } function fetchData( $data, $t_name, $row1=NULL, $rowdata1=NULL, $row2=NULL, $rowdata2=NULL, $switch=1 ) //fetch all data from a table. { $cm = $this->ppdia_conn; $t_name = $this->getTable($t_name); $rowdata1 = $this->getType($rowdata1); $rowdata2 = $this->getType($rowdata2); if ( !$data ) $data = '*'; if( !$row1 ) $sql = "SELECT " . $data . " FROM `" . $t_name . "`{$this->limit};"; else if ( !$row2 ) $sql = "SELECT " . $data . " FROM `" . $t_name . "` WHERE `" . $row1 . "`=" . $rowdata1 . "{$this->limit};"; else $sql = "SELECT " . $data . " FROM `" . $t_name . "` WHERE `" . $row1 . "`=" . $rowdata1 . " AND `" . $row2 . "`=" . $rowdata2 . "{$this->limit};"; $this->getDebug( $sql ); $result = $cm->query( $sql ); if($result) while( $res = $result->fetch_assoc() ) { $rawdata = $res; if( !empty($rawdata) ) { $output[] = $rawdata; } } if( !$switch ) $result->close; $this->getDebug( $output ); return $output; } function customQuery( $sql, $switch=1 ) { $cm = $this->ppdia_conn; $sql = $this->getTable($sql); $this->getDebug( $sql ); $result = $cm->query( $sql ); if( $result && ( preg_match("/select/",strtolower($sql)) || preg_match('/show fields/',strtolower($sql)) ) ) { if( preg_match("/from/",strtolower($sql)) ) { $res = array(); while( @$res[] = $result->fetch_assoc() ) { $output = $res; } } } $this->getDebug( $output ); return $output; } function checkTable() { $result = $this->fetchData( "", $this->getTableName() ); if( $result ) return true; else return false; } function deleteData( $table, $key, $value ) { $table = $this->getTable($table); $sql = "DELETE FROM `" . $table . "` WHERE `" . $key . "`='" . $value . "'"; $this->getDebug( $sql ); $deleted = $this->ppdia_conn->query($sql); return $this->ppdia_conn->affected_rows; } } Thanks I Just want the session to use on another file that need session to work may be the file that need the session is below <?php // PHP Script Chat - coursesweb.net define('MAXROWS', 30); // Maximum number of rows registered for chat define('CHATLINK', 1); // allows links in texts (1), not allow (0) // Here create the rooms for chat // For more rooms, add lines with this syntax $chatrooms[] = 'room_name'; $chatrooms = array(); $chatrooms[] = 'English'; $chatrooms[] = 'Government'; $chatrooms[] = 'Economics'; $chatrooms[] = 'Commerce'; $chatrooms[] = 'C.R.K'; // password used to empty chat rooms after this page is accessed with ?mod=admin define('CADMPASS', 'adminpass'); /* For example, access in your browser http://domain/chatfiles/setchat.php?mod=admin */ // If you want than only the logged users to can add texts in chat, sets CHATADD to 0 // And sets $_SESSION['username'] with the session that your script uses to keep logged users define('CHATADD', 0); if(CHATADD !== 1) { if(isset($_SESSION["9jsschoo_php_app"])) define('CHATUSER', $_SESSION["9jsschoo_php_app"]);; } // Name of the directory in which are stored the TXT files for chat rooms define('CHATDIR', 'chattxt'); include('texts.php'); // file with the texts for different languages $lsite = $en_site; // Gets the language for site if(!headers_sent()) header('Content-type: text/html; charset=utf-8'); // header for utf-8 // include the class ChatSimple, and create objet from it include('class.ChatSimple.php'); $chatS = new ChatSimple($chatrooms); // if this page is accessed with mod=admin in URL, calls emptyChatRooms() method if(isset($_GET['mod']) && $_GET['mod'] == 'admin') $chatS->emptyChatRooms(); this is the part where i have to put the session if(isset($_SESSION[""])) define('CHATUSER', $_SESSION[""]);; files that i suppose to contain the session
  8. just add this code any where in your preferable before the form. mail(youremail@domain.com, $_POST[full_name],$usr_email,$pass,$_POST[address],$_POST[tel],$_POST[fax],$_POST[web], $user_ip,$activ_code,$_POST[country],$user_name, "From: \"Member Registration\" <online@208.43.192.66>\r\n" . "X-Mailer: PHP/" ) to lazy too edit code please forgive me
  9. your mail fxn seem to be working fine are trying it on a localhost because that fxn won't work. If not you paste the error code here and this is his script for any one that wants to help. <?php /*************** PHP LOGIN SCRIPT V 2.0********************* ***************** Auto Approve Version********************** (c) Balakrishnan 2009. All Rights Reserved Usage: This script can be used FREE of charge for any commercial or personal projects. Limitations: - This script cannot be sold. - This script may not be provided for download except on its original site. For further usage, please contact me. ***********************************************************/ include 'dbc.php'; if($_POST['doRegister'] == 'Register') { function filter($arr) { return array_map('mysql_real_escape_string', $arr); } $_POST = filter($_POST); require_once('recaptchalib.php'); $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp->is_valid) { die ("<h3>Image Verification failed!. Go back and try again.</h3>" . "(reCAPTCHA said: " . $resp->error . ")"); } $user_ip = $_SERVER['REMOTE_ADDR']; $md5pass = md5($_POST['pwd']); $host = $_SERVER['HTTP_HOST']; $host_upper = strtoupper($host); $path = rtrim(dirname($_SERVER['PHP_SELF']), '/\\'); $activ_code = rand(1000,9999); $usr_email = mysql_real_escape_string($_POST['usr_email']); $user_name = mysql_real_escape_string($_POST['user_name']); $rs_duplicate = mysql_query("select count(*) as total from users where user_email='$usr_email' OR user_name='$user_name'") or die(mysql_error()); list($total) = mysql_fetch_row($rs_duplicate); if ($total > 0) { $err = urlencode("ERROR: The username/email already exists. Please try again with different username and email."); header("Location: register.php?msg=$err"); exit(); } $sql_insert = "INSERT into `users` (`full_name`,`user_email`,`pwd`,`address`,`tel`,`fax`,`website`,`date`,`users_ip`,`activation_code`,`country`,`user_name` ) VALUES ('$_POST[full_name]','$usr_email','$md5pass','$_POST[address]','$_POST[tel]','$_POST[fax]','$_POST[web]' ,now(),'$user_ip','$activ_code','$_POST[country]','$user_name' ) "; mysql_query($sql_insert,$link) or die("Insertion Failed:" . mysql_error()); $user_id = mysql_insert_id($link); $md5_id = md5($user_id); mysql_query("update users set md5_id='$md5_id' where id='$user_id'"); // echo "<h3>Thank You</h3> We received your submission."; $message = "Thank you for registering with us. Here are your login details...\n User ID: $user_name Email: $usr_email \n Passwd: $_POST[pwd] \n Activation code: $activ_code \n *****ACTIVATION LINK*****\n http://$host$path/activate.php?user=$md5_id&activ_code=$activ_code Thank You Administrator $host_upper ______________________________________________________ THIS IS AN AUTOMATED RESPONSE. ***DO NOT RESPOND TO THIS EMAIL**** "; mail($usr_email, "Login Details", $message, "From: \"Member Registration\" <online@208.43.192.66>\r\n" . "X-Mailer: PHP/" . phpversion()); header("Location: thankyou.php"); exit(); } ?> <html> <head> <title>PHP Login :: Free Registration/Signup Form</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script language="JavaScript" type="text/javascript" src="js/jquery-1.3.2.min.js"></script> <script language="JavaScript" type="text/javascript" src="js/jquery.validate.js"></script> <script> $(document).ready(function(){ $.validator.addMethod("username", function(value, element) { return this.optional(element) || /^[a-z0-9\_]+$/i.test(value); }, "Username must contain only letters, numbers, or underscore."); $("#regForm").validate(); }); </script> <link href="styles.css" rel="stylesheet" type="text/css"> </head> <body> <table width="100%" border="0" cellspacing="0" cellpadding="5" class="main"> <tr> <td colspan="3"> </td> </tr> <tr> <td width="160" valign="top"><p> </p> <p> </p> <p> </p> <p> </p> <p> </p></td> <td width="732" valign="top"><p> <? if (isset($_GET['done'])) { echo "<h2>Thank you</h2> Your registration is now complete and you can <a href=\"login.php\">login here</a>"; exit(); } ?></p> <h3 class="titlehdr">Free Registration / Signup</h3> <p>Please register a free account, before you can start posting your ads. Registration is quick and free! Please note that fields marked <span class="required">*</span> are required.</p> <? if (isset($_GET['msg'])) { $msg = mysql_real_escape_string($_GET['msg']); echo "<div class=\"msg\">$msg</div>"; } if (isset($_GET['done'])) { echo "<div><h2>Thank you</h2> Your registration is now complete and you can <a href=\"login.php\">login here</a></div>"; exit(); } ?> <br> <form action="register.php" method="post" name="regForm" id="regForm" > <table width="95%" border="0" cellpadding="3" cellspacing="3" class="forms"> <tr> <td colspan="2">Your Name / Company Name<span class="required"><font color="#CC0000">*</font></span><br> <input name="full_name" type="text" id="full_name" size="40" class="required"></td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2">Contact Address (with ZIP)<span class="required"><font color="#CC0000">*</font></span><br> <textarea name="address" cols="40" rows="4" id="address" class="required"></textarea> <span class="example">MUST BE VALID CONTACT DETAILS</span> </td> </tr> <tr> <td>Country <font color="#CC0000">*</font></span></td> <td><select name="country" class="required" id="select8"> <option value="" selected></option> <option value="Afghanistan">Afghanistan</option> <option value="Albania">Albania</option> <option value="Algeria">Algeria</option> <option value="Andorra">Andorra</option> <option value="Anguila">Anguila</option> <option value="Antarctica">Antarctica</option> <option value="Antigua and Barbuda">Antigua and Barbuda</option> <option value="Argentina">Argentina</option> <option value="Armenia ">Armenia </option> <option value="Aruba">Aruba</option> <option value="Australia">Australia</option> <option value="Austria">Austria</option> <option value="Azerbaidjan">Azerbaidjan</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="Bermuda">Bermuda</option> <option value="Bhutan">Bhutan</option> <option value="Bolivia">Bolivia</option> <option value="Bosnia and Herzegovina">Bosnia and Herzegovina</option> <option value="Brazil">Brazil</option> <option value="Brunei">Brunei</option> <option value="Bulgaria">Bulgaria</option> <option value="Cambodia">Cambodia</option> <option value="Canada">Canada</option> <option value="Cape Verde">Cape Verde</option> <option value="Cayman Islands">Cayman Islands</option> <option value="Chile">Chile</option> <option value="China">China</option> <option value="Christmans Islands">Christmans Islands</option> <option value="Cocos Island">Cocos Island</option> <option value="Colombia">Colombia</option> <option value="Cook Islands">Cook Islands</option> <option value="Costa Rica">Costa Rica</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="Dominica">Dominica</option> <option value="Dominican Republic">Dominican Republic</option> <option value="Ecuador">Ecuador</option> <option value="Egypt">Egypt</option> <option value="El Salvador">El Salvador</option> <option value="Estonia">Estonia</option> <option value="Falkland Islands">Falkland Islands</option> <option value="Faroe Islands">Faroe Islands</option> <option value="Fiji">Fiji</option> <option value="Finland">Finland</option> <option value="France">France</option> <option value="French Guyana">French Guyana</option> <option value="French Polynesia">French Polynesia</option> <option value="Gabon">Gabon</option> <option value="Germany">Germany</option> <option value="Gibraltar">Gibraltar</option> <option value="Georgia">Georgia</option> <option value="Greece">Greece</option> <option value="Greenland">Greenland</option> <option value="Grenada">Grenada</option> <option value="Guadeloupe">Guadeloupe</option> <option value="Guatemala">Guatemala</option> <option value="Guinea-Bissau">Guinea-Bissau</option> <option value="Guinea">Guinea</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="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="Kuwait">Kuwait</option> <option value="Kyrgyzstan">Kyrgyzstan</option> <option value="Lao People's Democratic Republic">Lao People's Democratic Republic</option> <option value="Latvia">Latvia</option> <option value="Lebanon">Lebanon</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="Marocco">Marocco</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="Moldavia">Moldavia</option> <option value="Monaco">Monaco</option> <option value="Mongolia">Mongolia</option> <option value="Myanmar">Myanmar</option> <option value="Nauru">Nauru</option> <option value="Nepal">Nepal</option> <option value="Netherlands Antilles">Netherlands Antilles</option> <option value="Netherlands">Netherlands</option> <option value="New Zealand">New Zealand</option> <option value="Niue">Niue</option> <option value="North Korea">North Korea</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="Republic of Korea Reunion">Republic of Korea Reunion</option> <option value="Romania">Romania</option> <option value="Russia">Russia</option> <option value="Saint Helena">Saint Helena</option> <option value="Saint kitts and nevis">Saint kitts and nevis</option> <option value="Saint Lucia">Saint Lucia</option> <option value="Samoa">Samoa</option> <option value="San Marino">San Marino</option> <option value="Saudi Arabia">Saudi Arabia</option> <option value="Seychelles">Seychelles</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="South Africa">South Africa</option> <option value="Spain">Spain</option> <option value="Sri Lanka">Sri Lanka</option> <option value="St.Pierre and Miquelon">St.Pierre and Miquelon</option> <option value="St.Vincent and the Grenadines">St.Vincent and the Grenadines</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="Thailand">Thailand</option> <option value="Trinidad and Tobago">Trinidad and Tobago</option> <option value="Turkey">Turkey</option> <option value="Turkmenistan">Turkmenistan</option> <option value="Turks and Caicos Islands">Turks and Caicos Islands</option> <option value="Ukraine">Ukraine</option> <option value="UAE">UAE</option> <option value="UK">UK</option> <option value="USA">USA</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="Vietnam">Vietnam</option> <option value="Virgin Islands (GB)">Virgin Islands (GB)</option> <option value="Virgin Islands (U.S.) ">Virgin Islands (U.S.) </option> <option value="Wallis and Futuna Islands">Wallis and Futuna Islands</option> <option value="Yemen">Yemen</option> <option value="Yugoslavia">Yugoslavia</option> </select></td> </tr> <tr> <td>Phone<span class="required"><font color="#CC0000">*</font></span> </td> <td><input name="tel" type="text" id="tel" class="required"></td> </tr> <tr> <td>Fax </td> <td><input name="fax" type="text" id="fax"> </td> </tr> <tr> <td>Website </td> <td><input name="web" type="text" id="web" class="optional defaultInvalid url"> <span class="example">http://www.example.com</span></td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2"><h4><strong>Login Details</strong></h4></td> </tr> <tr> <td>Username<span class="required"><font color="#CC0000">*</font></span></td> <td><input name="user_name" type="text" id="user_name" class="required username" minlength="5" > <input name="btnAvailable" type="button" id="btnAvailable" onclick='$("#checkid").html("Please wait..."); $.get("checkuser.php",{ cmd: "check", user: $("#user_name").val() } ,function(data){ $("#checkid").html(data); });' value="Check Availability"> <span style="color:red; font: bold 12px verdana; " id="checkid" ></span> </td> </tr> <tr> <td>Your Email<span class="required"><font color="#CC0000">*</font></span> </td> <td><input name="usr_email" type="text" id="usr_email3" class="required email"> <span class="example">** Valid email please..</span></td> </tr> <tr> <td>Password<span class="required"><font color="#CC0000">*</font></span> </td> <td><input name="pwd" type="password" class="required password" minlength="5" id="pwd"> <span class="example">** 5 chars minimum..</span></td> </tr> <tr> <td>Retype Password<span class="required"><font color="#CC0000">*</font></span> </td> <td><input name="pwd2" id="pwd2" class="required password" type="password" minlength="5" equalto="#pwd"></td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td width="22%"><strong>Image Verification </strong></td> <td width="78%"> <? require_once('recaptchalib.php'); echo recaptcha_get_html($publickey); ?> </td> </tr> </table> <p align="center"> <input name="doRegister" type="submit" id="doRegister" value="Register"> </p> </form> <p align="right"> </p> </td> <td width="196" valign="top"> </td> </tr> <tr> <td colspan="3"> </td> </tr> </table> </body> </html>
  10. It Works And i av add the view forum post ie view_topic.php and and add_answer.php and they all work perfectly well
  11. YOU ARE THE BOSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS IT WORKS LIKE MAGIC Please can i be your friend maybe on facebook or 2go
  12. i remove d result resouc it b4 using bt d same thing it shows blank and i fix it back it gave the error i want to try changing the ? to php
  13. Ch0cu3r You have always been Helping Me, am very great full thanks a lot and for more because I know am still a baby. Thanks once again.
  14. I tried out the code it gave an error Warning: mysql_affected_rows(): supplied argument is not a valid MySQL-Link resource in C:\wamp\www\forum\add_topic.php on line 25 Topic not added to table
  15. actually, sorry I left that out, the topic is added successfully to the data base. When i preview it in phpmyadmin portal i can see the post there but to view it is now the problem. But I will still check your script out. Thanks for more help.
  16. Am still a baby so please forgive me for too many Question. I have a simple forum Script. That is working very fine the problem is with viewing the posted topic I have 3 major file that anchor the forum my create_topic.php, add_topic.php and main_forum.php. All of them seem fine to except the main_forum.php for it is suppose to display the forum post but when ever i post a topic and try to view it i only get a blank table. The Post are stored in my local host database. These are the Scripts create_topic.php <table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <form id="form1" name="form1" method="post" action="add_topic.php"> <td> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td colspan="3" bgcolor="#E6E6E6"><strong>Create New Topic</strong> </td> </tr> <tr> <td width="14%"><strong>Topic</strong></td> <td width="2%">:</td> <td width="84%"><input name="topic" type="text" id="topic" size="50" /></td> </tr> <tr> <td valign="top"><strong>Detail</strong></td> <td valign="top">:</td> <td><textarea name="detail" cols="50" rows="3" id="detail"></textarea></td> </tr> <tr> <td><strong>Name</strong></td> <td>:</td> <td><input name="name" type="text" id="name" size="50" /></td> </tr> <tr> <td><strong>Email</strong></td> <td>:</td> <td><input name="email" type="text" id="email" size="50" /></td> </tr> <tr> <td> </td> <td> </td> <td><input type="submit" name="Submit" value="Submit" /> <input type="reset" name="Submit2" value="Reset" /></td> </tr> </table> </td> </form> </tr> </table> Next is add_topic.php <?php $host="localhost"; // Host name $username="root"; // Mysql username $password=""; // Mysql password $db_name="online"; // Database name $tbl_name="forum_question"; // Table name // Connect to server and select database. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // get data that sent from form $topic=$_POST['topic']; $detail=$_POST['detail']; $name=$_POST['name']; $email=$_POST['email']; $datetime=date("d/m/y h:i:s"); //create date time $sql="INSERT INTO $tbl_name(topic, detail, name, email, datetime)VALUES('$topic', '$detail', '$name', '$email', '$datetime')"; $result=mysql_query($sql); if($result){ echo "Successful<BR>"; echo "<a href=main_forum.php>View your topic</a>"; } else { echo "ERROR"; } mysql_close(); ?> and finally main_forum.php <?php $host="localhost"; // Host name $username="root"; // Mysql username $password=""; // Mysql password $db_name="online"; // Database name $tbl_name="forum_question"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM $tbl_name ORDER BY id DESC"; // OREDER BY id DESC is order result by descending $result=mysql_query($sql); ?> <table width="90%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td width="6%" align="center" bgcolor="#E6E6E6"><strong>#</strong></td> <td width="53%" align="center" bgcolor="#E6E6E6"><strong>Topic</strong></td> <td width="15%" align="center" bgcolor="#E6E6E6"><strong>Views</strong></td> <td width="13%" align="center" bgcolor="#E6E6E6"><strong>Replies</strong></td> <td width="13%" align="center" bgcolor="#E6E6E6"><strong>Date/Time</strong></td> </tr> <?php // Start looping table row while($rows=mysql_fetch_array($result)){ ?> <tr> <td bgcolor="#FFFFFF"><? echo $rows['id']; ?></td> <td bgcolor="#FFFFFF"><a href="view_topic.php?id=<? echo $rows['id']; ?>"><? echo $rows['topic']; ?></a><BR></td> <td align="center" bgcolor="#FFFFFF"><? echo $rows['view']; ?></td> <td align="center" bgcolor="#FFFFFF"><? echo $rows['reply']; ?></td> <td align="center" bgcolor="#FFFFFF"><? echo $rows['datetime']; ?></td> </tr> <?php // Exit looping and close connection } mysql_close(); ?> <tr> <td colspan="5" align="right" bgcolor="#E6E6E6"><a href="create_topic.php"><strong>Create New Topic</strong> </a></td> </tr> </table> mysql script Table forum_question CREATE TABLE `forum_question` ( `id` int(4) NOT NULL auto_increment, `topic` varchar(255) NOT NULL default '', `detail` longtext NOT NULL, `name` varchar(65) NOT NULL default '', `email` varchar(65) NOT NULL default '', `datetime` varchar(25) NOT NULL default '', `view` int(4) NOT NULL default '0', `reply` int(4) NOT NULL default '0', PRIMARY KEY (`id`) ) TYPE=MyISAM AUTO_INCREMENT=1 ; Table forum_answer CREATE TABLE `forum_answer` ( `question_id` int(4) NOT NULL default '0', `a_id` int(4) NOT NULL default '0', `a_name` varchar(65) NOT NULL default '', `a_email` varchar(65) NOT NULL default '', `a_answer` longtext NOT NULL, `a_datetime` varchar(25) NOT NULL default '', KEY `a_id` (`a_id`) ) TYPE=MyISAM; Please My magic Programmers Help me out.Thanks In advance
  17. I have a php registration Script with a php form validation. The Validation seems to be working fine But it is independent of mysql insert query so wether the form input is correct or not the data will still be sink into the data base. <!DOCTYPE html> <html lang="en"> <head> <meta content="en-us" http-equiv="Content-Language"> <link rel="stylesheet" href="style.css" type="text/css" media="all"> <title> Register Page </title> </head> <body> <div id="wrapper"> <!--header--> <?php include("include/header.php"); ?> <!-- end header--> <!-- nav--> <?php include("include/nav.php"); ?> <!-- end nav--> <!-- left bar--> <?php include("include/left_bar.php"); ?> <!-- end left bar--> <!-- content--> <div id="content" align="left"> <form method="post" action="check_register.php"> First Name: <br><input type="text" name="fname" ><br> <?php if (isset($_POST["submit"])&&(empty($fname))) { echo"<center><em><div id='form'>Please Your Frist Name Is Required<br></div></em></center>";}?> Last Name: <br><input type="text" name="lname" ><br> <?php if (isset($_POST["submit"])&&(empty($lname))) { echo"<center><em><div id='form'>Please Your Last Name Is Required<br></div></em></center>";}?> User Name: <br><input type="text" name="username" ><br> <?php if (isset($_POST["submit"])&&(empty($username))) { echo"<center><em><div id='form'>Please Your User Name Is Required<br></div></em></center>";}?> Email:<br> <input type="email" name="email" ><br> <?php if (isset($_POST["submit"])&&(empty($email))) { echo"<center><em><div id='form'>Please Your Email Is Required<br></div></em></center>";}?> Password: <br><input type="Password" name="password" ><br> <?php if (isset($_POST["submit"])&&(empty($password))) { echo"<center><em><div id='form'>Please a Password Is Required<br></div></em></center>";}?> Phone: <br><input type="tel" name="phone" ><br> <?php if (isset($_POST["submit"])&&(empty($phone))) { echo"<center><em><div id='form'>Please Your Number Is Required<br></div></em></center>";}?> Gender: <br><input type="text" name="gender" ><br> <?php if (isset($_POST["submit"])&&(empty($gender))) { echo"<center><em><div id='form'>Please Your Gender Is Required<br></div></em></center>";}?> <input type="submit" name="submit" value="Register"> </form> </div> <!-- end content--> <!-- right bar--> <?php include("include/right_bar.php"); ?> <!-- end right bar--> <!-- footer--> <?php include("include/footer.php"); ?> </div> <!-- end footer--> </body> </html> that is my register.php that contain the php form validation. Here is check_register that contains the mysql query Someone Please Use master eye and Spot the Problem for me <?php $host="localhost"; $dbuser="root"; $dbpass=""; $db_name="login"; $db_table="login"; mysql_connect("$host","$dbuser","$dbpass") or die("Could Not Establish Connection"); mysql_select_db("$db_name")or die(mysql_error()); $fname=$_POST["fname"]; $lname=$_POST["lname"]; $username=$_POST["username"]; $email=$_POST["email"]; $password=$_POST["password"]; $phone=$_POST["phone"]; $gender=$_POST["gender"]; //validation of input in the form fieldS include("register.php"); $submit=mysql_query("INSERT INTO users(fname,lname,username,email,password,phone,gender)VALUES('$fname','$lname','$username','$email','$password','$phone','$gender')") or die("REGISTRATION NOT COMPLETED Thanks"); if($submit==TRUE){ Echo"<div style='background:yellow;'><script>alert('YOU HAVE SUCESSFULLY REGISTERED PLEASE LOGIN WITH YOUR USERNAME AND PASSWORD');</script></div>"; } ?>
  18. Alpine i love you am very greatful you dnt knw what you have done for me am very happy. thank we have you in this forum
  19. now i av hash only my insert into database and unhash my compare with pin alpine u r a pure genius
  20. ooooookkkk u r tooo goood my master i encrypt my form pass and the database pin is not i think dat z d cos i av applied ur method and it work
  21. pin is name of field in the pin_code and then add a dumie data say 1234dagogo now wen am registring i would use 1234dagogo as d password and on my database pin_code is the table which u know and pin is the name of the field
  22. ohh am sorry you ask if: I answered Yes. Reason been that they will buy the pin code from web master and use then use it as their password when registering on the site and the pin code will be inserted into the database. so when the user buy a database inserted pincode he use it as it password and then register with it. so he will be allowed bcos d pin code is in the database
×
×
  • 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.