PHP - Open Two Pages On Same Page..!
this is my code which is using to check login from database calledchklogin.php
Code: [Select] <?php session_start(); include('connect.php'); $tbl_name="members"; mysql_select_db($Db, $link); // username and password sent from form $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; // To protect MySQL injection (more detail about MySQL injection) $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword); $mypassword = md5($mypassword); $sql="SELECT * FROM $tbl_name WHERE uname='$myusername' and upass='$mypassword'"; $result=mysql_query($sql,$link); $row=mysql_fetch_array($result); // 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("username"); //Create the session session_register("myusername"); session_register("mypassword"); $_SESSION['uname'] = "$myusername"; $_SESSION['utype'] = $row['utype']; header("location:loginsuccess.php"); } else { //include ('index.php'); echo ("<script type='text/javascript'> window.alert('Wrong username or password!')</script>"); exit(); } ?> & this code is from another file called loginsuccess.php Code: [Select] <? session_start(); if(!session_is_registered(myusername)){ header("location:index.php"); exit(); } require_once("login-index.php"); ?> so when everything is right in chklogin.php then it open loginsuccess.php after that when all is true then it open login-index.php after that this page open it show double page one is index.php where the login form & another is this login-index.php at one time Similar TutorialsHello, I'm new here and need some help. I'm a beginner with PHP Here's what I have.... The index page looks like this: <? include("header.php"); ?> <? include("sidebar.php"); ?> <? include("main.php"); ?> <? include("footer.php"); ?> On all of the pages for the site, the only thing that will change will be: <? include("main.php"); ?> When viewing the home page, the title in the browser shows: Home Page (which is what I want). However, when clicking on links in the nav bar, I want the title to reflect those page names. For example, the code above displays the home page, but then if you click on (for example) "Bio's" in the navigation bar, it will take you to the Bio's page, obviously. the link for that menu item is: bio.php. The bio.php page looks like this: <? include("header.php"); ?> <? include("sidebar.php"); ?> <div> All the data and formatting for this page </div> <? include("footer.php"); ?> ............. I would like to put some php code in the header that will automatically detect the title of each page, how can I do this? Should I put <? title=Bio's Page ?> (or whatever page) at the top of each page, then call to it somehow from the header? Any help would be appreciated. Hi there again all I am making a site that has a popout music player. My question is since the player is opened by javascript is there a way to let the original page know that the popout is open? Hi guys so i want to make page acces to certain ranks. So im thinking for something like this
rank1 -> home.php, admins.php So the ranks are in a database with the page names. So now when someone logs in they will get a certain rank. So now i need to make a function that will check if the rank has access to this page. $curPageName = substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1); This will detect the current page that the logged in person is at now. But now how do i check if the $_SESSION['rank']; (rank1) has the access to get in page admins.php, and obviously to make $_SESSION['rank'];(rank2) redirect from the page admins.php Could someone point me in the right direction? Do i select the ranks and page names from database then put it into a array? Thanks. I have script on my web hosts server built into pages that will be offered to the public, eg: index.php will have some script amongst the html, this script calls other webpages on the net eg: wiki.org Now my question is, when that script runs when somebody accesses that page, will the website eg: wiki.org record the users browser info and ip who called my index page or will it record the webhosts server details as the one making the requests? Can i open a pdf within a page? e.g. within <td> or <table> of htmls so that it appears on a section of a page where someone can just read through and still able to browse the web page. I dont want the PDF downloading or taking the whole page or even opening a new window and filling it. Thanks in advance. Sorry for my bad english but i hope you would understand my query. How can i set 404 not found for database driven pages..? I am using header("HTTP/1.0 404 Not Found"); in my 404 error page and ErrorDocument 404 /404.html, whereas 404.html is my error page. i have an URL http://www.example.com/folder/my-test-for-url-95/ which is opening correctly because it has existence on database. but when i am opening http://www.example.com/folder/my-test-for-url-951/ which has existence on database is also opening without any information but i want here a 404 not found page. How can i do so. Thanks Hi everyone, I have this script that identify's the current page in the navigation Code: [Select] <?php $currentPage = basename($_SERVER['SCRIPT_NAME']); ?> <ul id="nav"><!-- Open Nav --> <li><a href="index2.php" <?php if ($currentPage == 'index2.php') {echo 'class="selected"';} ?>>Home</a></li> <li><a href="salon-information.php" <?php if ($currentPage == 'salon-information.php') {echo 'class="selected"';} ?>>Salon Information</a></li> <li><a href="about-us.php" <?php if ($currentPage == 'about-us.php') {echo 'class="selected"';} ?>>About us</a></li> <li><a href="hair-care-advice.php" <?php if ($currentPage == 'hair-care-advice.php') {echo 'class="selected"';} ?>>Hair Care Advice</a></li> </ul><!-- Close Nav --> My problem is that hair-care-advice.php has a number of sub pages. How do I get it so the selected class remains selected for all the sub pages as well as the main page. Any help would be greatly appreciated Thank you Barry Hi Everyone, I have an ecommerce store that I have done some coding for, and each category has some coding to create pages to display items in that category. For some reason, I am getting a couple of "ghost" pages on the end of a couple categories. For example, look at this page: http://www.autismcommunitystore.com/view.php?category=4 Pages 5 & 6 are blank - page 4 has the last of the items in the category. I have a table called prods_to_cats which connects the products and the categories (a many to many relationship). I'm posting the code here - could someone just let me know if they spot something that looks like trouble? Thank you in advance for your time! Code: [Select] <? $category=$_REQUEST['category']; $showcategory=$category; include 'connect.php'; $thiscategory = mysql_query("SELECT * FROM category WHERE category_id=$showcategory", $dbh); $thisrow = mysql_fetch_array($thiscategory); $this_des=$thisrow["category_description"]; $this_text=$thisrow["category_text"]; $titlekey="Products listed in $this_des at Autism Community Store 877-422-5932"; // If current page number, use it // if not, set one! if(!isset($_GET['page'])){ $page = 1; } else { $page = $_GET['page']; } // Define the number of results per page $max_results = 40; // Figure out the limit for the query based // on the current page number. $from = (($page * $max_results) - $max_results); echo '<div id="product">'; $result = mysql_query("SELECT DISTINCT product.id, product.* FROM prods_to_cats INNER JOIN product ON prods_to_cats.id=product.id WHERE prods_to_cats.category_id=$showcategory ORDER BY product.title ASC LIMIT $from, $max_results", $dbh); $numresult = mysql_num_rows($result); if($numresult==0) { echo "<p style='padding-left: 50px'>There are no products listed in this category.</p>\n"; } else { $thiscategory = mysql_query("SELECT * FROM category WHERE category_id=$showcategory", $dbh); $thisrow = mysql_fetch_array($thiscategory); $this_des=$thisrow["category_description"]; echo "<table width='100%'><tr>"; echo "<div style='position:relative; left:150px;'><font size='2'>Return To: <strong><a href='http://www.autismcommunitystore.com'>Home </a></strong></font></div><br/>"; echo "<div style='position:relative ; width:100%' align='center'>"; echo "<br />"; echo "<img src='http://www.watchesandthings.com/autism/images/suppliesHeader.gif'>"; echo "</div>"; echo "<h2>"; echo "<div style='padding-right:20px ; position:relative ; width;100%; text-align:right;'>"; echo "<div style='position:relative ; width;80%; text-align:center; left:20%;'>"; echo $this_des; echo "</div>"; echo "</div>"; echo "</h2>"; echo "<div style='position:relative ; padding-left:30px ; padding-right:30px ; '>"; echo "<p>"; echo "$this_text </p>"; echo "</div>"; echo "</tr>"; $count = 1; $column = 1; //initialize column 1 or 2 //-----------------------code for drop down menu---------------------------------------- include 'browserChecker.php'; /* echo $browser; echo "<br/>"; echo $browser_version; echo "<br/>"; $main_version=$browser_version[0]; echo $main_version; */ if ($browser=='IE' && $browser_version<7){ echo '<br />'; //make version 6 compatible select box if ($category==1 || $category==24){ }else{ ?> <center> <div id="hiddendiv" style="display:;"> <form method="get" enctype="multipart/form-data" action="http://www.autismcommunitystore.com/viewsubcategory.php"> <select id="myselectbox" name="subcategory" > <? $sql="SELECT * FROM subcategory ORDER BY sub_description ASC"; $result=mysql_query($sql, $dbh); while($myrow=mysql_fetch_array($result)) { if ($myrow['category_id']==$category){ $myrow['sub_description'] ?> <option name="subcategory" value="<? echo $myrow['sub_id'] ?>" ><? echo $myrow['sub_description'] ?> </option> <? }//close if for category check }//close drop down while loop ?> </select> </center> <div id="go_subcat"> <input type="submit" value=" GO " style="background-color: #E4DFF3; color: #6F5079; border: 2px solid #6F5079"> </div> </form> </div> <? }//end check category }else{ //make normal select box if ($category==1 || $category==24){ }else{ ?><div style="z-index:2"><br /><form method="get" enctype="multipart/form-data" action="http://www.autismcommunitystore.com/viewsubcategory.php"> <div align="center" style='z-index:5'> <select name="subcategory" size="1" style="background-color: #ffffff; color: #6F5079; border: 2px solid #6F5079"> <? $sql="SELECT * FROM subcategory ORDER BY sub_description ASC"; $result=mysql_query($sql, $dbh); while($myrow=mysql_fetch_array($result)) { if ($myrow['category_id']==$category){ ?> <option name="subcategory" value="<? echo $myrow['sub_id'] ?>" ><? echo $myrow['sub_description'] ?> </option> <? }//close if for category check }//close drop down while loop ?> </select> <input type="submit" value=" GO " style="background-color: #E4DFF3; color: #6F5079; border: 2px solid #6F5079"> </div> </form> </div> <? } }//end browser checker if //-----------------------end code for drop down menu---------------------------------------- //reste variables $result = mysql_query("SELECT DISTINCT product.id, product.* FROM prods_to_cats INNER JOIN product ON prods_to_cats.id=product.id WHERE prods_to_cats.category_id=$showcategory ORDER BY product.title ASC LIMIT $from, $max_results", $dbh); echo "<TABLE cellspacing='20'>"; while($myrow = mysql_fetch_array($result)) { extract($myrow); $location=$image; $price=$sale_price; $item=$myrow["id"]; $stockstatus=$stat; if($stat=='IN STOCK') { $stockstatus=""; } else { $stockstatus="--Item Coming Soon--"; } if($price>0) { $printout="<table border=0 height=70 width=250><tr><td width='100px' align='center' ><a href=http://www.autismcommunitystore.com/item/$item/><img src=http://www.watchesandthings.com/autism/files/thumbnails/$location border=0 alt=$product_id></a></td><td><a href=http://www.autismcommunitystore.com/item/$item/>$title</a><br><span class=prod-dollar>$$price</span><br>$stockstatus</td></tr></table>"; } else { $printout="<table border=0 height=70 width=250><tr><td width='100px' align='center' ><a href=http://www.autismcommunitystore.com/item/$item/><img src=http://www.watchesandthings.com/autism/files/thumbnails/$location border=0 alt=$product_id></a></td><td><a href=http://www.autismcommunitystore.com/item/$item/>$title<br /><span class=prod-dollar>Click for Pricing</span></a><br>$stockstatus</td></tr></table>"; } if ($column=="1") { echo "<tr><td>$printout</td>"; // first column } else { echo "<td>$printout</td></tr>"; // 2nd column } // end of columns $count += 1; // this is a modulus operator it gets the remainder of the equation $column = $count % 2; } // end of while loop echo "</table>"; ; // Figure out the total number of results in DB: $total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM prods_to_cats WHERE category_id=$showcategory"),0); //$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM product"),0); // Figure out the total number of pages. Always round up using ceil() $total_pages = ceil($total_results / $max_results); echo "<p><center>Pages<br />"; // Build Previous Link if($page > 1){ $prev = ($page - 1); echo "<a href='http://www.watchesandthings.com/autism/view.php?category=$showcategory&page=$prev'><<Previous</a> "; } for($i = 1; $i <= $total_pages; $i++){ if(($page) == $i){ echo "$i "; } else { echo "<a href='http://www.watchesandthings.com/autism/view.php?category=$showcategory&page=$i'>$i</a> "; } } // Build Next Link if($page < $total_pages){ $next = ($page + 1); echo "<a href='http://www.watchesandthings.com/autism/view.php?category=$showcategory&page=$next'>Next>></a>"; } echo "</center>"; }//end of else> echo "</table>"; echo "</div>"; ?> I'm trying to set up a very simple (WIP) members page that you can click registered users to see their profile page that will display basic information. I'm having trouble with the sessions and retrieving this info from my database. I'm very new to this so it's all pretty amateur. I've been looking at this code for several hours trying to fix things but I start to make some progress, then change stuff, and go backwards. I had a members page that displayed the registered users in my database, but after a while of altering to try to get the profiles to work, I messed it up :mad:. I have basic login and register pages. I need some seperate eyes to take a look. Any help is so much appreciated. Thanks! members.php Code: [Select] <?php session_start(); require 'mysql-connect.php'; $auser=$_SESSION['user']; if(isset($auser)){ $Members = mysql_query("SELECT * FROM user WHERE username='$username'") or die(mysql_error()); $numRowsMembers = mysql_num_rows($Members); ?> <table border="1"> <?php for($count = 1; $count <= $numRowsMembers; $count++) { $name = mysql_fetch_array($Members); ?> <tr> <?php echo '<td><a href="member_profile.php?username=' . $name['username'] . '">' . $name['username'] . '</a></td>'; } } ?> </tr> </table> member_profile.php Code: [Select] <?php session_start(); require 'mysql-connect.php'; $auser=$_SESSION['user']; if(isset($auser)){ $username = $_GET['username']; $user = mysql_query("SELECT * FROM user WHERE username = '$username'"); echo $user; $user=mysql_fetch_assoc($user); echo "<h1>User Info</h1>"; echo "<b>Username:".$user['username']."<br>"; echo "<br>"; echo '<form name="backlistfrm" method="post" action="members.php">'; echo '<input type="submit" value="Back to The List">'; echo '</form>'; echo "<br>"; } ?> my login handler Code: [Select] <?php include 'mysql-connect.php'; $username = $_POST['user']; $password = $_POST['pass']; $query1 = mysql_query("SELECT * FROM user WHERE username='$username'"); $result = mysql_num_rows($query1); if($result == 0) { echo '<h1>Error!</h1>The username you specified does not exist!'; } else { $checkuser = mysql_query("SELECT * FROM user WHERE username='$username'"); $row = mysql_fetch_array($checkuser); $password2 = $row['password']; //$status = $row['status']; if ($password == $password2) { echo "Hi $username."; include("index.php"); } else { echo '<h1>Error!</h1>The username and password combination you entered does not match the ones we have in the database.'; } } ?> mysql-connect.php Code: [Select] <?php $host = "localhost"; $username = "root"; $password = ""; $database = "ug54"; $link = mysql_connect($host, $username, $password);//Connects to database with host, username, and password $select = mysql_select_db($database); ?> and my simple database Code: [Select] CREATE TABLE IF NOT EXISTS `user` ( `id` int(4) unsigned NOT NULL AUTO_INCREMENT, `username` varchar(32) NOT NULL, `password` varchar(32) NOT NULL, `firstname` varchar(20) NOT NULL, `lastname` varchar(20) NOT NULL, `email` varchar(30) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ; -- -- Dumping data for table `user` -- INSERT INTO `user` (`id`, `username`, `password`, `firstname`, `lastname`, `email`) VALUES (1, '', '', '', '', '0'), (2, 'abc', '123', '', '', '0'), (3, 'a', 'b', 'c', 'd', '0'), (4, 'hfg', 'rgfdg', 'gdfg', 'dfgdf', '0'), (5, '999', '999', '999', '999', '999'); when the user clicks the submit button from a html form, it needs to go back two pages with that loaded page refreshed. for the javascript i only have history.go(-2); with php, I have tried cookies and sessions which i discovered that neither will work because the loaded page is not refreshed. I could do a html body onload but that would break the w3c validator. what are my options?
i am facing issue with DB connection with Oracle DB able to telnet and connect DB from [RHEL] OS command prompt also when i am executing php command with php filename, i am able to connect to the database. i am getting err 500 when trying to open php page from front end.
pls help...!!!! Hi, I was just wondering if it were possible (and if so how) to open a page in a new window when submitting a form via php? E.g. I have a poll on my website that is directed to the reults page by $insertGoTo = "results.php";. This all works but what I want to happen is for when the user clicks submit that the results page displays in a new window (or at the very least a new tab), similar to what would happen when you put a target=_blank on a html link. Any help would be very appreciated. Thanks. Hi all . I have a script , which will display the records from sql . If user wish to view more details of the record , they can click view . Code: [Select] echo "<td>$objResult[Message] </td>"; echo "<td>$objResult[mylocaltime] </td>"; echo '<td><a href="historydetails.php?id=' . $objResult[Groupnumber] . '">View</a></td>'; Then it will link to a page which will display more details according to the Groupnumber . Which will display 2 records per page . Code: [Select] <? $groupnumber = $_GET['id']; $strSQL = "SELECT * FROM esp WHERE Groupnumber='$groupnumber'"; $objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]"); $Num_Rows = mysql_num_rows($objQuery); $Per_Page = 2; // 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; } $strSQL .=" order by id DESC LIMIT $Page_Start , $Per_Page"; $objQuery = mysql_query($strSQL); ?> But when I click next to view the third record , then the table will become blank . Is it because when I click to next page , the $groupnumber is no longer getting the data from $_GET['id'] ? Or is there any other problem? Thanks for every reply . Hi Guys, I wonder if you can help me before I go crazy? I have the task of updating a site by adding text to every page, at the moment there are three pages on the live website that show both images and text, I am to update the remaining 6 with text to go with the images.... I thought this was all fine and dandy, added the text in, checked the code, uploaded to the FTP site and nothing, only 1 page worked. I am stuck as I have used the same method to add text to all the pages yet those elusive pages refuse to show text! This is driving me crazy and i am hoping that one of you guys has come across this before and will be able to highlight a missing piece of code or have a solution? I do appreciate your time and any suggestions that you have. I have attached the page below. Thanks guys! hello dear phpfreaks running linux opensuse 11.4 and mozilla well - how can i donwload a site that i see with the mozilla-browser and afterwards open it with GIMP whats the easiest way to do such thigns!? love to hear from you greetings db1 This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=355108.0 i want a code in php to check if user open this page This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=356195.0 Hello there, I'm trying to make when you click on a record, it opens another page with full details about this record the code for it is Code: [Select] <td><a href=\"user.php?id=".$row['id']."\">".$row['id']."</a></td> and it's working right, but when it opens the other page, no records is shown about the user with that ID So I figure the problem that I need to pass $row['id'] to my second page and make it search for it in the database how can I do that? here is the code from the second page (details of the record) Code: [Select] $dbObj = new DB(); $result = mysql_query("select * from users where id = '$userID'"); return $result; $row = @mysql_fetch_array($result); echo "<table width=98%>"; echo "<tr>"; echo "<td valign=\"top\" width=\"120px\">"; $rowid = $row['id']; echo "<td valign=\"top\">"; echo "<table> <tr> <td valign=\"top\" class=\"searchtitle\"> ".$row['fname']. ' ' .$row['mname']. ' ' .$row['lname']." </td> </tr> <tr> <td class=\"text\" valign=\"top\"> ".$row['mobile']." </td> </tr> <tr> <td> <a href=\"user.php?id=".$row['recruiterid']."\" class=\"link\">".$row['recruiterid']."</a> </td> </tr> </table>"; echo "</td>"; echo "</tr>"; echo "</table>"; I'm trying to open a URL using fopen() and I keep getting this error: Code: [Select] Failed to open stream: Permission deniedI can not work out what is wrong, it's not a firewall as far as I can tell. |