runnerjp Posted April 22, 2008 Share Posted April 22, 2008 hey guys i use this link to go to a users profile <a href="<?php echo get_username($_SESSION['user_id']);?> "> this basicly with the help of htaccess RewriteEngine on RewriteBase / RewriteRule ^([^/.]+)/?$ members/profile.php?username=$1 RewriteRule ^([^/.]+)/?$ members/profile.php?id=$1 makes is so you can go to the users profile and their data will appear profile.php <?php include '../index.php';?> <?php session_start(); require_once '../settings.php'; $query = "SELECT * FROM users WHERE Username = '$username' LIMIT 1"; if ($result = mysql_query($query)){ if (mysql_num_rows($result)) { $array = mysql_fetch_assoc($result); $pemail = $array['Email']; $puser = $array['Username']; $pid = $array['ID']; $pfirst_name = $array['first_name']; $plast_name = $array['last_name']; $pabout_me = $array['about_me']; $pevents = $array['events']; $pgender = $array['gender']; $pdob = $array['dob']; $sql = "SELECT `ext` FROM `user_images` WHERE `user_id`='$pid' LIMIT 1"; ?> <title><?php echo $puser; ?>'s profile</title><body> <table width="100%"> <tr> <td colspan="4"> <div class="c1"> <div align="center"> <p>Welcome to <?php echo $puser; ?>'s profile </p> <p> </p> </div> </div> </td> </tr> <tr> <td width="7%"><?php $q = mysql_query($sql) or die("Error running query:".mysql_error()); if($q && mysql_num_rows($q) > 0) { $row = mysql_fetch_array($q); if(!empty($row)) { echo "<img src='http://www.runningprofiles.com/members/images/thumbs/". $pid . "." . $row['ext'] . "'"; } else { echo 'no image'; } } ?></td> <td width="26%">i am <?php echo $pgender;?> and my bday is <?php echo $pdob; ?> </td> <td width="45%"></td> <td width="22%" bordercolor="#000000" bgcolor="#99b3b4"><p>Name: <?php echo $pfirst_name; ?><?php echo $plast_name; ?></p> <p> </p> <p>About me:</p> <?php echo $pabout_me; ?></td> </tr> </table> <?php } else { echo "<center>Sorry no users with that name can be found within our database </center><br />"; } } else { echo "Query failed<br />$sql<br />" . mysql_error(); } ?> </body> </html> this all works fine.... but recently i have added this <? $page = $_GET['page']; if (ereg('[A-Za-z0-9]',$page) ) { if (file_exists('include/'.$page.'.php')) { include('include/'.$page.'.php'); } else { include('include/main.php'); } } else { include('include/main.php'); }?> but the code for this is http://www.mywebsite.com/members/index.php?section=(what ever the page) so how can i combine this http://www.mywebsite.com/members/index.php?section=?? and <a href="<?php echo get_username($_SESSION['user_id']);?> "> to get it all to work :S:S Link to comment https://forums.phpfreaks.com/topic/102298-cannot-figure-out-how-to-get-rewrite-and-get_page-to-work-s/ Share on other sites More sharing options...
runnerjp Posted April 22, 2008 Author Share Posted April 22, 2008 bmp Link to comment https://forums.phpfreaks.com/topic/102298-cannot-figure-out-how-to-get-rewrite-and-get_page-to-work-s/#findComment-523886 Share on other sites More sharing options...
runnerjp Posted April 22, 2008 Author Share Posted April 22, 2008 bmp Link to comment https://forums.phpfreaks.com/topic/102298-cannot-figure-out-how-to-get-rewrite-and-get_page-to-work-s/#findComment-523970 Share on other sites More sharing options...
runnerjp Posted April 22, 2008 Author Share Posted April 22, 2008 bmp Link to comment https://forums.phpfreaks.com/topic/102298-cannot-figure-out-how-to-get-rewrite-and-get_page-to-work-s/#findComment-524318 Share on other sites More sharing options...
runnerjp Posted April 23, 2008 Author Share Posted April 23, 2008 any hlp today? Link to comment https://forums.phpfreaks.com/topic/102298-cannot-figure-out-how-to-get-rewrite-and-get_page-to-work-s/#findComment-524781 Share on other sites More sharing options...
runnerjp Posted April 23, 2008 Author Share Posted April 23, 2008 ok i have had a mess around i have done this.... ok i have changed my htaccess file to this RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^/.]+)/?$ members/include/profile.php?username=$1 RewriteRule ^([^/.]+)/?$ members/include/profile.php?id=$1 in the include file i have added my profile.php and used a link on members/index.php like so <a href="?page=<?php echo get_username($_SESSION['user_id']);?> "> user</a> but when i click the link in the address bar it comes up with http://www.runningprofiles.com/members/index.php?page=username but just refreshes the index.php and does not take me to the users profile page... how comes? Link to comment https://forums.phpfreaks.com/topic/102298-cannot-figure-out-how-to-get-rewrite-and-get_page-to-work-s/#findComment-524981 Share on other sites More sharing options...
runnerjp Posted April 23, 2008 Author Share Posted April 23, 2008 bmp Link to comment https://forums.phpfreaks.com/topic/102298-cannot-figure-out-how-to-get-rewrite-and-get_page-to-work-s/#findComment-525129 Share on other sites More sharing options...
runnerjp Posted April 23, 2008 Author Share Posted April 23, 2008 do i need to do something like this RewriteRule ^([^/.]+)/?$ members/index.php?page=?username=$1 (obviusly this does not work or i would not be posting hehe) Link to comment https://forums.phpfreaks.com/topic/102298-cannot-figure-out-how-to-get-rewrite-and-get_page-to-work-s/#findComment-525151 Share on other sites More sharing options...
runnerjp Posted April 23, 2008 Author Share Posted April 23, 2008 ? Link to comment https://forums.phpfreaks.com/topic/102298-cannot-figure-out-how-to-get-rewrite-and-get_page-to-work-s/#findComment-525383 Share on other sites More sharing options...
runnerjp Posted April 23, 2008 Author Share Posted April 23, 2008 RewriteRule ^([^/.]+)/?$ members/index.php?page=?username=$1 i belive its deffently this but im not 100% sure how i would make this accurate... altho i could be completely wrong lol has no 1 got any ideas of this at all? i have also added RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d as i read i needed this what does it do? Link to comment https://forums.phpfreaks.com/topic/102298-cannot-figure-out-how-to-get-rewrite-and-get_page-to-work-s/#findComment-525484 Share on other sites More sharing options...
runnerjp Posted April 24, 2008 Author Share Posted April 24, 2008 bmp Link to comment https://forums.phpfreaks.com/topic/102298-cannot-figure-out-how-to-get-rewrite-and-get_page-to-work-s/#findComment-525822 Share on other sites More sharing options...
runnerjp Posted April 24, 2008 Author Share Posted April 24, 2008 io think no 1ns answering because im not been too clear so i will help u guys out so u can help me out by explainin better ok on my index.php under members i have thiscode <? $page = $_GET['page']; if (ereg('[A-Za-z0-9]',$page) ) { if (file_exists('include/'.$page.'.php')) { include('include/'.$page.'.php'); } else { include('include/main.php'); } } else { include('include/main.php'); }?> so anything under my members/include folder can be displayed in this area by this url http://www.mywebsite.com/members/index.php?section=what ever i want up but im having trouble pulling peoples profiles up what i have been doing is having a mod rewrite placed in members folder RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^/.]+)/?$ members/profile.php?username=$1 RewriteRule ^([^/.]+)/?$ members/profile.php?id=$1 so if this is typed www.website.com/members/user then users profile will come up. but i want to add it into the index.php?section= part. so i added my profile.php into include section and created the link <a href="?page=<?php echo get_username($_SESSION['user_id']);?> "> user</a> but all it does is refresh the default page of main.php do i need to chnage the rewrite code? is this clearer ?? Link to comment https://forums.phpfreaks.com/topic/102298-cannot-figure-out-how-to-get-rewrite-and-get_page-to-work-s/#findComment-525846 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.