PHP - Error In Cms Login System With Ie. It Works Fine With Chrome.
FOR the CMS go to http://sandeepthapa.com.np/project/admin
and login in username: user pasword: 123456 with both Chrome and IE. pleease and site is http://sandeepthapa.com.np/project/ it works fine with Chrome, but not with IE. please help me this is my first CMS . i am learning.. it i use joommla templetefor design. oz i am not a designer //..here is the code for process_login.php page <?php require_once("includes/session.php"); ?><?php require_once("includes/connection.php"); ?><?php require_once("includes/functions.php"); ?><?php if (logged_in()) { redirect_to("content.php"); } if (isset($_POST['submit'])) { if(!$_POST['username']) { echo ' Make sure u type in username'; } if( !$_POST['password']) { echo 'make sure you type password'; } $username = trim(mysql_prep($_POST['username'])); $password = trim(mysql_prep($_POST['password'])); $hashed_password = sha1($password); // Check database to see if username and the hashed password exist there. $query = "SELECT id, username "; $query .= "FROM users "; $query .= "WHERE username = '{$username}' "; //$query .= "AND hashed_password = '{$hashed_password}' "; $query .= "AND hashed_password = '{$hashed_password}' "; $query .= "LIMIT 1"; $result_set = mysql_query($query) or die(mysql_error()); if(!$result_set) {die("Database connection failed: " . mysql_error());} confirm_query($result_set); if (mysql_num_rows($result_set) == 1) { // username/password authenticated // and only 1 match $found_user = mysql_fetch_array($result_set); //echo $found_user['id']; $_SESSION['user_id'] = $found_user['id']; $_SESSION['username'] = $found_user['username']; //echo 'test query'; redirect_to("content.php"); } } else { echo 'error'.mysql_error(); } ?> </body> </html> Similar TutorialsHi guys. What I want to create is really complicated. Well I have a login system that works with post on an external website. I have my own website, but they do not give me access to the database for security reasons, therefore I have to use their login system to verify my users. What their website does is that it has a post, with username and password. The POST website is lets say "https://www.example.com/login". If login is achieved (i.e. username and password are correct), it will redirect me to "https://www.example.com/login/success" else it will redirect me to "https://www.example.com/login/retry". So I want a PHP script that will do that post, and then according to the redirected website address it will return me TRUE for success, FALSE for not successful login. Any idea?? Thanks I have created a script (single file) that works fine when testing it alone, but when included it doesn't and rest of page is blank. What could cause this? Is this because of some "mismatch" between the queries, variables used on the included file and the existing file? Code: [Select] <?php $objConnect = mysql_connect("localhost","","cgdfgdfg") or die(mysql_error()); $objDB = mysql_select_db("ffdfvbbd"); $pic2 = "SELECT * FROM images"; if (!isset($_GET['Page'])) $_GET['Page']='0'; $pic1 = mysql_query($pic2); $Num_Rows = mysql_num_rows($pic1); $Per_Page = 16; // Per Page $Page = $_GET["Page"]; if(!$_GET["Page"]) {$Page=1;} $Prev_Page = $Page-1; $Next_Page = $Page+1; $Page_Start = (($Per_Page*$Page)-$Per_Page); if($Num_Rows<=$Per_Page) {$Num_Pages =1;} else if(($Num_Rows % $Per_Page)==0) {$Num_Pages =($Num_Rows/$Per_Page) ;} else {$Num_Pages =($Num_Rows/$Per_Page)+1; $Num_Pages = (int)$Num_Pages;} $pic2 .="ORDER by thumbnailID DESC LIMIT $Page_Start , $Per_Page" ; $pic1 = mysql_query($pic2); $cell = 0; $link1 = "SELECT * FROM images"; echo ' <div id="tablediv"> <table border="0" cellpadding="17" cellspacing="0" class="table"> <tr>'; while($pic = mysql_fetch_array($pic1)) { if($cell % 4 == 0) { echo '</tr><tr>'; } if($cell == 2) { echo ' <td> filler </td>'; } elseif ($cell == 3) { echo ' <td> filler </td>'; } else { echo ' <td> <a href="/' . $pic["link"] . '.php"> <div class="image"> <img src="https://s3.amazonaws.com/images/' . $pic["pic"] . '.png" alt="' . $pic["alt"] . '" height="200" width="200" /> </div> </a> </td>'; } $cell++; } echo '</tr></table></div>'; ?>The code above works just fine. However, once I add a WHERE function,as shown below, I get a "Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource" error. Code: [Select] <?php $objConnect = mysql_connect("localhost","","cgdfgdfg") or die(mysql_error()); $objDB = mysql_select_db("ffdfvbbd"); $pic2 = "SELECT * FROM images WHERE folder = 'blog' "; //WHERE FUNCTION IS HERE if (!isset($_GET['Page'])) $_GET['Page']='0'; $pic1 = mysql_query($pic2); $Num_Rows = mysql_num_rows($pic1); $Per_Page = 16; // Per Page $Page = $_GET["Page"]; if(!$_GET["Page"]) {$Page=1;} $Prev_Page = $Page-1; $Next_Page = $Page+1; $Page_Start = (($Per_Page*$Page)-$Per_Page); if($Num_Rows<=$Per_Page) {$Num_Pages =1;} else if(($Num_Rows % $Per_Page)==0) {$Num_Pages =($Num_Rows/$Per_Page) ;} else {$Num_Pages =($Num_Rows/$Per_Page)+1; $Num_Pages = (int)$Num_Pages;} $pic2 .="ORDER by thumbnailID DESC LIMIT $Page_Start , $Per_Page" ; $pic1 = mysql_query($pic2); My mysql table includes column thumbnailID folder link pic alt time The folder column is there so I can specify what I want in the page. Anyhow, why won't it work? Good day dear community. I need to build a function which parses the domain from a url. I have used various ways to parse html sources. But this one is is a bit tricky! See the target i want to parse - it has some invaild Markup: http://www.schulministerium.nrw.de/BP/SchuleSuchen?action=644.0013008534253&SchulAdresseMapDO=194190 well what do you think - can i apply this code here <?php require_once('config.php'); // call config.php for db connection $filename = "url.txt"; // Include the txt file which have urls $each_line = file($filename); foreach($each_line as $line_num => $line) { $line = trim($line); $content = file_get_contents($line); //echo ($content)."<br>"; $pattern = '/<td>(.*?)<\/td>/si'; preg_match_all($pattern,$content,$matches); foreach ($matches[1] as $match) { $match = strip_tags($match); $match = trim($match); //var_dump($match); $sql = mysqli_query("insert into tablename(contents) values ('$match')"); //echo $match; } } ?> well i have to rework the parser-part of this script. I need to parse somway different - since i have other site here. Can anybody help me here to get a better regex - or a better way to parse this site ... Any and all help will be greatly apprecaited. regards db1 I am having a very difficult time working out what to look at next. I have a page and it will not fopen a new file or an existing one to write. Even though I have a couple of other pages that copy into the same location without trouble. My PHP is 5.2.13 on W2k3 IIS. Here is the code that works; copy($myDir.$file, "\\\\Eeyore\\TempEDI\\".$file); Here is the code that fails; $fileN = "\\\\Eeyore\\TempEDI\\alley.txt"; $fh1 = fopen($fileN, 'wb'); I have tried with and without the new file already existing. I have checked NTFS permissions and the Share permissions. The webserver in use is remote to the files. I have turned on File level object access auditing on the Eeyore server (also win2k3) and the fopen call does not even hit the Eeyore server, I can see all other access to the file and folder but nothing from the page in question. Safe_mode and Opendirbase are both unset in php.ini. All I want to do is make a text file and add some lines of text, this problem is absolutely infuriating. Hello everyone, I'm having this problem which is really annoying, tried to solve it but couldn't, I write that code in PHPMyAdmin and it works great, but it doesn't work in the website it self ok long story short, there are three tables, hotels, cities, countries hotels include in addition to hotel info, 2 columns (city_id) and (country_id) Cities include id and name and also countries include id and name what I was trying to do, that when a person inputs a city or country name in the search form, it should get the hotels that exists in this city or country, but unfortunately it shows all the hotels in all cities and countries, although the pagination code for number of pages works just fine, it count the number of hotels in that city or country and show the number of pages correctly so here is the code for both for hotel search Code: [Select] class hotelManager { public function getHotel($where) { $where = isset($_POST['where']) ? $_POST['where'] : ""; $dbObj = new DB(); $sql = "select * from hotels where city_id = (select id from cities where name = '$where' ) or country_id = (select id from countries where name = '$where' )"; $result = MYSQL_QUERY($sql); $arr = array(); echo "<table>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td valign=\"top\" width=\"120px\">"; $rowid = $row['id']; $imageqry=mysql_query("SELECT * FROM `hotelphotos` where hotel_id='$rowid' LIMIT 1"); $image=mysql_fetch_array($imageqry); $imagename=$image['attachmentName']; echo "<img src=\"foxmaincms/webroot/files/small/$imagename\"/>"; echo "</td>"; echo "<td valign=\"top\">"; echo "<table> <tr> <td valign=\"top\"> <a href=\"hotels.php?id=".$row['id']."\" class=\"titleslink\">".$row['name']."</a> </td> </tr> <tr> <td class=\"text\" valign=\"top\"> ".$row['location']." </td> </tr> </table>"; echo "</td>"; echo "</tr>"; } echo "</table>"; for hotel pagination Code: [Select] <?php include("includes/hotelsManager.php"); $hotelObj = new hotelManager(); $where = isset($_POST['where']) ? $_POST['where'] : ""; if(isset($_POST['where'])) { $hotelObj -> getHotel($where); $per_page = 9; //Calculating no of pages $sql = "select * from hotels where city_id = (select id from cities where name = '$where' ) or country_id = (select id from countries where name = '$where' )"; $result = MYSQL_QUERY($sql) or die("<br />No Hotels found in this city, please check the city name and try again"); $count = mysql_num_rows($result); $pages = ceil($count/$per_page) ?> <div id="loading" ></div> <div id="maincontent" ></div> <ul id="pagination"> thank you in advance Hi all, I wonder if any of you have this problem before.. I have a login page with "checked box remember me" - It is working fine in my localhost machine I can see the COOKIE in my browser's option setting (Firefox). But now the problem is: When I run the script in my test server; and do exactly the same thing..the COOKIE did not seem know. When I logged in as an admin and checked the box. And closed all the browser. Then, open the browser (Firefox)and go to the index page (landing page) then it redirect me to the login page instead. I looked the at COOKIE setting in my Firefox and I can it is stored there. Any ideas whats wrong? I have strange problem with SOAP. My file SchoolAPI look like that: <?php require_once('../require/constants.php'); require_once('../require/connection.inc.php'); class SchoolAPI{ private $dbh; public function __construct() { $this->dbh = new PDO(DRIVER.':host='.HOST.';dbname='.DB, USER, PASSWORD); } //function return all subcjects public function getSubjects(){ $sth = $this->dbh->prepare(' SELECT id, nazwa ROM subjects'); $sth->execute(); return $sth->fetchAll(PDO::FETCH_NUM); //return array(array("1", "subject1"),array("2", "subject2")); } //function return all classes public function getClasses(){ $sth = $this->dbh->prepare(' SELECT id, nazwa FROM classes'); $sth->execute(); return $sth->fetchAll(PDO::FETCH_NUM); //return array(array("1", "class1"),array("2", "class2")); } } ini_set("soap.wsdl_cache_enabled", "0"); $server = new SoapServer("SchoolAPI.wsdl"); $server->setClass("SchoolAPI"); $server->handle(); ?> wsdl file is named SchoolAPI.wsdl and look like that: <wsdl:definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://schema.example.com" targetNamespace="http://schema.example.com" > <wsdl:types> <xsd:schema targetNamespace="http://schema.example.com"> <xsd:complexType name="myarry2"> <xsd:sequence> <xsd:element minOccurs="0" maxOccurs="unbounded" name="row" nillable="true" type="xsd:string" /> </xsd:sequence> </xsd:complexType> </xsd:schema> <xsd:schema targetNamespace="http://schema.example.com"> <xsd:complexType name="myarray"> <xsd:sequence> <xsd:element minOccurs="0" maxOccurs="unbounded" name="table" nillable="true" type="tns:myarry2" /> </xsd:sequence> </xsd:complexType> </xsd:schema> </wsdl:types> <wsdl:message name="getSubjectsRequest"></wsdl:message> <wsdl:message name="getSubjectsResponse"> <part name="getSubjectsReturn" type="tns:myarray"/> </wsdl:message> <wsdl:message name="getClassesRequest"></wsdl:message> <wsdl:message name="getClassesResponse"> <part name="getClassesReturn" type="tns:myarray"/> </wsdl:message> <wsdl:portType name="SchoolAPIPortType"> <wsdl:operation name="getSubjects"> <wsdl:input message="tns:getSubjectsRequest"/> <wsdl:output message="tns:getSubjectsResponse"/> </wsdl:operation> <wsdl:operation name="getClasses"> <wsdl:input message="tns:getClassesRequest"/> <wsdl:output message="tns:getClassesResponse"/> </wsdl:operation> </wsdl:portType> <wsdl:binding name="SchoolAPIBinding" type="tns:SchoolAPIPortType"> <soap:binding transport="http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation name="getSubjects"> <soap:operation soapAction="urn:SchoolAPI/getSubjects" style="document"/> <wsdl:input> <soap:body use="literal"/></wsdl:input> <wsdl:output><soap:body use="literal"/></wsdl:output> </wsdl:operation> <wsdl:operation name="getClasses"> <soap:operation soapAction="urn:SchoolAPI/getClasses" style="document"/> <wsdl:input> <soap:body use="literal"/></wsdl:input> <wsdl:output><soap:body use="literal"/></wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="SchoolAPI"> <wsdl:port name="SchoolAPIPort" binding="tns:SchoolAPIBinding"> <soap:address location="http://localhost:82/myschool/webservices/SchoolAPI.php" /> </wsdl:port> </wsdl:service> </wsdl:definitions> The problem is that correct data is returned olny by first function declarated in <wsdl:binding> section. In this example correct data will be return by getSubjects function, and function getClassses return null. However, if we change order and put getClasses operation first in binding section like this: <wsdl:binding name="SchoolAPIBinding" type="tns:SchoolAPIPortType"> <soap:binding transport="http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation name="getClasses"> <soap:operation soapAction="urn:SchoolAPI/getClasses" style="document"/> <wsdl:input> <soap:body use="literal"/></wsdl:input> <wsdl:output><soap:body use="literal"/></wsdl:output> </wsdl:operation> <wsdl:operation name="getSubjects"> <soap:operation soapAction="urn:SchoolAPI/getSubjects" style="document"/> <wsdl:input> <soap:body use="literal"/></wsdl:input> <wsdl:output><soap:body use="literal"/></wsdl:output> </wsdl:operation> </wsdl:binding> then correct data will be return by getClasses function, and getSubjects will return null. Do you know what is going on? I do my best to solve this problem and I have no idea what is wrong... hi i have the script below which copies data from one table to another but will only insert new data update current data or delete old data from tempproducts to products then it will delete the tempproducts from the db however i keep getting this error: Warning: mssql_query() [function.mssql-query]: Query failed in E:\UpdateProducts.php on line 33 updateproducts.php Code: [Select] <?php include('../../otherscripts/functions.php'); $log = new Logging(); // create DB connection $host = "localhost"; $user = "user"; $pass = "pass"; $mydb = "db"; $db = mssql_connect($host,$user,$pass); //Select Database mssql_select_db($mydb); // delete all old data $sql0 = "SELECT * FROM tempproduct"; $sql1 = "INSERT INTO products SELECT * FROM tempproduct WHERE manf_part_no NOT IN (SELECT manf_part_no FROM products) AND supp_id NOT IN (SELECT supp_id FROM products)"; $sql2 = "DELETE FROM products WHERE manf_part_no NOT IN (SELECT manf_part_no FROM tempproduct) AND supp_id NOT IN (SELECT supp_id FROM tempproduct)"; $sql3 = "UPDATE p1 SET p1.avail_qty = t1.avail_qty, p1.cost_price = t1.cost_price, p1.rrp = t1.rrp, p1.date_added = t1.date_added, p1.description = t1.description FROM Products p1 INNER JOIN tempproduct t1 ON (p1.manf_part_no = t1.manf_part_no AND p1.supp_id = t1.supp_id)"; $sql4 = "TRUNCATE TABLE tempproduct"; //If tempproduct is empty done Execute Commands if it is full then execute commands $query = mssql_query($sql0) or die($log->lwrite('Failed to select for count from db')); $rowcount = mssql_num_rows($query); if($rowcount == 0){ $log->lwrite('Teh tempproduct am emptyish'); } else{ mssql_query($sql1) or die($log->lwrite('Failed to insert to db'.$sql1)); mssql_query($sql2) or die($log->lwrite('Failed to Delete from db')); mssql_query($sql3) or die($log->lwrite('Failed to Update db')); mssql_query($sql4) or die ($log->lwrite('Failed to TRUNCATE db')); } ?> if i run $sql1 command in the sql manager it runs fine and no errors occur? I have this form action that checks for errors, if none are found it should go to the confirmation page. Works well in Firefox, however Chrome stays perpetually on the register page. Is there any way to make this work in Chrome as well? Does anyone have any explanation? Thank you very much for your time. Code: [Select] <form action="<?php if(!empty($errors)){ echo "confirmation.php"; } else { echo "register.php"; } ?>" method="POST"> Hello, New to file upload boxes, working in PHP. My code seems to work great in IE, but not in Firefox or Chrome. This form shows the input box for the filename in IE and Firefox (with a Browse button), but Chrome only shows the Browse button, no filename box. <form enctype="multipart/form-data" method="post" action="profile.php"> <input type="file" size="32" name="image_field_photo" value=""> <br><input type="submit" name="Submit" value="Upload"> IE will upload the file to the specified directory, then update the DB based on the filename. Firefox will not upload the file, nor will Chrome. Using SSL for all pages. Using an upload class I got off PHPClasses.org - what's weird is I have used this same class on another project, and can upload files via Chrome. Any ideas? Thanks! Here is the scenario: I have phpbb installed inside of an iframe and I have all of these features working .....in firefox only: Iframe re-sizes to fit content external links within the forum open in a new window traffic to my /forum directory is redirected (with a javascript window.location.replace) to open inside of the iframe Essentially phpbb works perfectly in firefox When I load it in either Chrome or IE: My site index will load fine (as will any site feature that is not within the iframe) When I attempt to load my forum or request anything within the iframe IE and Chrome show the page for less than one second then continuously load a 404 page within the frame This leads me to believe that it is a problem with my redirect...but I have no clue. Here is the PHP, hopefully somebody can help: Iframe re-size code (in iframefile.php): <script type="text/javascript"> /*********************************************** * IFrame SSI script II- &#169; Dynamic Drive DHTML code library (http://www.dynamicdrive.com) * Visit DynamicDrive.com for hundreds of original DHTML scripts * This notice must stay intact for legal use ***********************************************/ //Input the IDs of the IFRAMES you wish to dynamically resize to match its content height: //Separate each ID with a comma. Examples: ["myframe1", "myframe2"] or ["myframe"] or [] for none: var iframeids=["myframe"] //Should script hide iframe from browsers that don't support this script (non IE5+/NS6+ browsers. Recommended): var iframehide="yes" var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1] var FFextraHeight=parseFloat(getFFVersion)>=0.1? 150 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers function resizeCaller(){ var dyniframe=new Array() for (i=0; i<iframeids.length; i++){ if (document.getElementById) resizeIframe(iframeids[i]) //reveal iframe for lower end browsers? (see var above): if ((document.all || document.getElementById) && iframehide=="no"){ var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i]) tempobj.style.display="block" } } } function resizeIframe(frameid){ var currentfr=document.getElementById(frameid) if (currentfr && !window.opera){ currentfr.style.display="block" if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight; else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax currentfr.height = currentfr.Document.body.scrollHeight; if (currentfr.addEventListener) currentfr.addEventListener("load", readjustIframe, false) else if (currentfr.attachEvent){ currentfr.detachEvent("onload", readjustIframe) // Bug fix line currentfr.attachEvent("onload", readjustIframe) } } } function readjustIframe(loadevt) { var crossevt=(window.event)? event : loadevt var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement if (iframeroot) resizeIframe(iframeroot.id); } function loadintoIframe(iframeid, url){ if (document.getElementById) document.getElementById(iframeid).src=url } if (window.addEventListener) window.addEventListener("load", resizeCaller, false) else if (window.attachEvent) window.attachEvent("onload", resizeCaller) else window.onload=resizeCaller </script> _________________________________________________ ___ This is (part of) the javascript redirect (in iframefile.php) <script type="text/javascript"> var text = window.location.href; function delineate(str) { theleft = str.indexOf("=") + 1; theright = str.indexOf("&"); return(str.substring(theleft, str.length)); } url=delineate(text) function refreshFrame() { myframe.location.replace("http://www.mydomain/?var1='+window.location.href+'"); } </script> This is the other part of the above javascript redirect that is in the overall_header to redirect pages requested within the forum to target the iframe via the code above: <script type="text/javascript"> if (window == top) { var url='window.location.replace("/?var1='+window.location.href+'")'; eval(url); } </script> This is the necessary code i had to add in my home directory index.php for the above two codes to work: <? ob_start(); $vary = $_GET['var1']; $tee = $_GET['t']; if ( $vary == "" ) { // do nothing, no var } else { $gogogo = strtolower($vary); $healthy = array("http://mydomain/forum/", "http://www.mydomain/forum/"); $yummy = array("", ""); $newphrase = str_replace($healthy, $yummy, $gogogo); $finalcode = base64_encode($newphrase); $healthy = array("+", "="); $yummy = array("7PLUS7", "7EQUALS7"); $newphraseu = str_replace($healthy, $yummy, $finalcode); if ( $tee == "" ) { header("Location: http://www.mydomain/iframefile.php?var=$newphraseu"); } else { header("Location: http://www.mydomain/iframefile.php?var=$newphraseu&t=$tee"); } } ob_flush(); ?> ___________________________________ And finally this is the code for my actual iframe (in iframefile.php): <? $healthy = array("7PLUS7", "7EQUALS7"); $yummy = array("+", "="); $newphraseu = str_replace($healthy, $yummy, $vary); $finally = base64_decode($newphraseu); if ( $tee == "" ) { $thedone = $finally; } else { $thedone = "$finally&t=$tee"; } if ( $vary == "" ) { ?> <center><iframe onload="refreshFrame();" id="myframe" src="/forum" scrolling="no" marginwidth="0" frameborder="0" marginheight="0" vspace="0" hspace="0" style="overflow:invisible; width:100%; display:none"></iframe></center> <? } else { ?> <center><iframe onload="refreshFrame();" id="myframe" src="/forum/<? echo $thedone; ?>" scrolling="no" marginwidth="0" marginheight="0" frameborder="0" vspace="0" hspace="0" style="overflow:invisible; width:100%; display:none"></iframe></center> <? } ?> Sorry for the long read. Again this all works perfect in firefox but with IE and Chrome the iframe keeps reloading a 404 page after showing the requested page briefly. Any and all help is appreciated! Thanks in advance I'm trying to build a login system and alot of the code is similar to what i used to make my news cms. basically all i wanna accomplish right now is to get the user input inserted into my database. I've already tested it out, and I get no errors, but like with the cms, the database isn't getting queryed. Here's the code: (process.php) Code: [Select] <?php $first_name=$_POST['first_name']; $last_name=$_POST['last_name']; $age=$_POST['age']; $city=$_POST['city']; $state=$_POST['state']; $country=$_POST['country']; $zip=$_POST['zip']; $birthdate=$_POST['birthdate']; $gender=$_POST['gender']; $sexuality=$_POST['sexuality']; $race=$_POST['race']; $religion=$_POST['religion']; $status=$_POST['status']; $about=$_POST['about']; $website=$_POST['website']; $user_name=$_POST['user_name']; $password=$_POST['password']; $email=$_POST['email']; mysql_connect("your hostname", "your database name", "your password") or die(mysql_error()); mysql_select_db("your database name") or die(mysql_error()); $sql = sprintf("INSERT INTO Users (first_name, last_name, age, city, state, country, zip, birthdate, gender, sexuality, race, religion, status, about, website, user_name, password, email) VALUES ('%s', '%s', '%s', '%s', '%s')", mysql_real_escape_string($first_name), mysql_real_escape_string($last_name), mysql_real_escape_string($age), mysql_real_escape_string($city), mysql_real_escape_string($state), mysql_real_escape_string($country), mysql_real_escape_string($zip), mysql_real_escape_string($birthdate), mysql_real_escape_string($gender), mysql_real_escape_string($sexuality), mysql_real_escape_string($race), mysql_real_escape_string($religion), mysql_real_escape_string($status), mysql_real_escape_string($about), mysql_real_escape_string($website), mysql_real_escape_string($user_name), mysql_real_escape_string($password), mysql_real_escape_string($email)); $result = mysql_query($sql); Print "Congratulations! You are now a registered member on yourwebsite.com!"; ?> (register/index.php) Code: [Select] <script language = "Javascript"> function Validate() { if (document.register.first_name.value == '') { alert('You have not specified your first name!'); return false; } if (document.register.last_name.value == '') { alert('You have not specified your last name!'); return false; } if (document.register.age.value == '') { alert('You have not specified your age!'); return false; } if (document.register.country.value == '') { alert('You have not entered a country!'); return false; } if (document.register.birthdate.value == '') { alert('You have not entered your date of birth!'); return false; } if (document.register.gender.value == '') { alert('You have not specified your gender!'); return false; } if (document.register.user_name.value == '') { alert('You have not entered a username!'); return false; } if (document.register.email.value == '') { alert('You have not entered an email!'); return false; } if (document.register.password.value == '') { alert('You have not entered a password!'); return false; } return true; } </script> <form name="register" method="post" action="http://www.djsmiley.net/register/process.php" onsubmit="return Validate();"> <table width="100%" border="0"> <tr> <td>First Name:</td> <td><label> <input type="text" name="first_name" id="first_name" /> </label></td> </tr> <tr> <td>Last Name:</td> <td><input type="text" name="last_name" id="last_name" /></td> </tr> <tr> <td>Age:</td> <td><input type="text" name="age" id="age" /></td> </tr> <tr> <td>City:</td> <td><input type="text" name="city" id="city" /></td> </tr> <tr> <td>State:</td> <td><input type="text" name="state" id="state" /></td> </tr> <tr> <td>Country:</td> <td><input type="text" name="country" id="country" /></td> </tr> <tr> <td>Zip:</td> <td><input type="text" name="zip" id="zip" /></td> </tr> <tr> <td>Birthdate:</td> <td><input type="text" name="birthdate" id="birthdate" /></td> </tr> <tr> <td>Gender:</td> <td><input type="text" name="gender" id="gender" /></td> </tr> <tr> <td>Sexuality:</td> <td><input type="text" name="sexuality" id="sexuality" /></td> </tr> <tr> <td>Race:</td> <td><input type="text" name="race" id="race" /></td> </tr> <tr> <td>Religion:</td> <td><input type="text" name="religion" id="religion" /></td> </tr> <tr> <td>Marital Status:</td> <td><input type="text" name="status" id="status" /></td> </tr> <tr> <td>About You:</td> <td><label> <textarea name="about" id="about" cols="45" rows="5"></textarea> </label></td> </tr> <tr> <td>Website:</td> <td><input type="text" name="website" id="website" /></td> </tr> <tr> <td width="13%">Username: </td> <td width="87%"><input type="text" name="user_name" id="user_name" /></td> </tr> <tr> <td>Email: </td> <td><input type="text" name="email" id="email" /></td> </tr> <tr> <td>Password: </td> <td><input type="password" name="password" id="password" /></td> </tr> <tr> <td> </td> <td><input name="Register Button" type="submit" class="Button1" id="Register Button" value="Register" /> <input name="Reset Button" type="reset" class="Button1" id="Reset Button" value="Clear" /></td> </tr> </table> <label></label> </form> Hi, im getting alot of errors like so Deprecated: Function session_is_registered() is deprecated time to update some files, can you guys pls help im rubbish with PHP guess thats why I waited so long to update. here is the code I need to change checklogin.php // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ // Register $myusername, $mypassword and redirect to file "login_success.php" session_register("myusername"); session_register("mypassword"); header("location:index.php"); } index.php <? session_start(); /*if(!session_is_registered(myusername)){ header("location:main_login.php"); }*/ ?> index.php (display username stuff) <?php if(session_is_registered(myusername)){ ?> Welcome: <?= $_SESSION['myusername'] ?><?php } ?> index.php (edit content stuff) <?php $file = file_get_contents('content/menu_header_a.txt', 'r'); if(session_is_registered(myusername)){ ?><a href="javascript:open4()"><?php echo $file ?></a><?php } else { echo $file; }?> Many thanks for any and all your help with this one. if you could keep it simple please like ( replace this with this ) . thanks I've abandoned my old script and switched to this one: http://www.evolt.org/node/60384 I got it working on my site just fine (djsmiley.net/members/register - you can test it out if u want). i just want to know how i can put all of the code into the pages i created using my template. It doesn't specify how this can be done in the tutorial, which is why im confused. I've tried everything but keep getting errors. Help? Hi Everyone, Just a quick question before I take on this project. Basically the client has a secure server set up with folders for different clients. So they can store excel files, PDFs etc, What the client use to do was send the client an email with the http address of that clients particular folder to be able to login. What my job is to create a login system that redirects each client to their particular area on the secure system. Is this going to be difficult, What I was thinking of doing was when the administator is setting up the client details there would be an extra field saying address: they paste the address of the folder on the server. Then it will redirect them to their folder. Is this the correct way to do this. Any help or advice would be great. ok i need directing to a tutorial, an easyish one that can help me do a secure login and registration system. Something that uses sessions and mysql. something with sql injection and other security. i need it very secure. hope you can help. Hi could you help me get this login page working?
I made a form which posts to login.php the "user" and "pass".
Then this is my code for login.php: <?php include("mysql_connect.inc.php"); ?> <?php $user = $_POST['user']; $pass = $_POST['pass']; session_start(); $query = mysqli_query("SELECT * FROM users WHERE username='$user'"); $results = mysqli_query($con, $query) or die(mysqli_error($con)); $resultsarray = mysql_fetch_array($userresults); if (isset($_POST['user']) && $_POST['user'] == $query && isset($_POST['pass']) && $_POST['pass'] == $query) { $_SESSION['username'] = $_POST['user']; echo "<p>Login success. You are logged in as: " . $_SESSION['username'] . "</p>Return to mainpage, click <a href='index.php'>here</a>!"; } else { echo "<p>Wrong username or password.</p>"; } mysqli_close($con); ?> |