General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 12th, 2003, 01:18 PM
dfano dfano is offline
Always Learning (I Think)
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: NYC Baby!!!!
Posts: 123 dfano User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via AIM to dfano Send a message via Yahoo to dfano
User Login - url redirection?

if i create a db table that has: USER, PASSWORD, URL

how can i make each user go to their specific url when they login.

user 1 goes to user1.htm
user 2 goes to user2.htm
and so on

i have no code to post because i have not started yet i am looking more for the pseudo code or theory. but i guess an exaple would help.

Thanks
Dave
www.fs3d.com

Reply With Quote
  #2  
Old July 12th, 2003, 01:55 PM
_rainbow_ _rainbow_ is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Lj, Slovenia
Posts: 27 _rainbow_ User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 28 sec
Reputation Power: 0
The function you are looking for is header(). An example:

PHP Code:
 header("Location: user1.htm"); 


Be careful with this function. It sends raw HTTP headers, wich means you musn't print out any other chars, even a space is not allowed, wich is usually the common mistake.

If you find it difficult using it this way (if you keep getting errors) try using it with the ob_start() and ob_end_flush() functions to make your way around your errors. Hope it helps a bit.

Reply With Quote
  #3  
Old July 12th, 2003, 02:15 PM
dfano dfano is offline
Always Learning (I Think)
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: NYC Baby!!!!
Posts: 123 dfano User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via AIM to dfano Send a message via Yahoo to dfano
i want user user1.htm to be a from the data base how do i tell PHP that user1.htm correspondes to the user1 data base field or is there a way to tell PHP to look with in the same row for the URL.

i hope this is clear,

Thanks

Dave

Reply With Quote
  #4  
Old July 12th, 2003, 04:55 PM
_rainbow_ _rainbow_ is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Lj, Slovenia
Posts: 27 _rainbow_ User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 28 sec
Reputation Power: 0
Well in that case, you have to get the users name from the database (I trust you know how to do that), then lets say you save that name in the variable $user. The line looks like this:

PHP Code:
 header("Location: $user.htm"); 


This will take each user to their site. But why are you doing this like this? Imagine that you have a large number of users, why bother making a site for each and every one of them. Make a template page and just change what you need for each user with a script. On the other hand if you have only a few users, could prove usefull. Anywayz, hope you explain a bit further why you need this to begin with.

Reply With Quote
  #5  
Old July 12th, 2003, 04:59 PM
dfano dfano is offline
Always Learning (I Think)
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: NYC Baby!!!!
Posts: 123 dfano User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via AIM to dfano Send a message via Yahoo to dfano
i am a small web designer and i want to create a place where my clients can log in and see their site before it is published and some other information that they may not want to be public. and lastly if it works out how i want it to it might be cool.

Thanks for the help, i think that will work perfect.

i am new to PHP

Dave

Last edited by dfano : July 12th, 2003 at 05:06 PM.

Reply With Quote
  #6  
Old July 12th, 2003, 05:03 PM
_rainbow_ _rainbow_ is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Lj, Slovenia
Posts: 27 _rainbow_ User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 28 sec
Reputation Power: 0
Cheers. Glad to have helped.

Reply With Quote
  #7  
Old July 12th, 2003, 05:08 PM
dfano dfano is offline
Always Learning (I Think)
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: NYC Baby!!!!
Posts: 123 dfano User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via AIM to dfano Send a message via Yahoo to dfano
what if the user name is differnt from url
real example:

Username : jason
url : chandlerarchitecture.com

the way you posted before will work fine, im just curious.

Dave

Reply With Quote
  #8  
Old July 12th, 2003, 05:18 PM
_rainbow_ _rainbow_ is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Lj, Slovenia
Posts: 27 _rainbow_ User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 28 sec
Reputation Power: 0
Well make another field in the database (lets say lates_site or something). Well all you have to do is to save the addres in there. In this case you could save the whole addres in there (with the extension .htm or .php) and use a simpler line:

PHP Code:
 header("Location: $latest_site"); 


Well I would do it like that...

Reply With Quote
  #9  
Old July 12th, 2003, 06:29 PM
dfano dfano is offline
Always Learning (I Think)
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: NYC Baby!!!!
Posts: 123 dfano User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via AIM to dfano Send a message via Yahoo to dfano
it would look in the same row that user is in?

Reply With Quote
  #10  
Old July 12th, 2003, 07:34 PM
nicat23's Avatar
nicat23 nicat23 is offline
Addicted to Chaos..
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jan 2003
Location: Ft. Worth, TX
Posts: 653 nicat23 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 47 m 52 sec
Reputation Power: 0
Send a message via AIM to nicat23 Send a message via Yahoo to nicat23
What you could do, is in your database where you have your client information stored, for example if you have it setup like this
Quote:
username, password, custname, coname , custaddress, custphone, customerurl


then you could pull the customers url out of the database and send that information to the header, ie:
PHP Code:
if ($dbConn){ //this assumes that you already 
    //successfully connected to the database
    
$strQuery "select * from siteusers "
    
$strQuery .= "where username = '$username'"
    
$strQuery .= " and password = '$userpass'"
//This also assumes that you already have the username and password
    
$results mysql_query($strQuery); 
    
$result mysql_fetch_row($results); 
    if (
$result){ 
        
$CustURL $result[6]; 
        
header("Location: $CustURL");
    } else{ 
        echo 
"No results returned.";
    } 



That would pull the information you would need to redirect to the customers website, otherwise it would justecho "No results returned." or something similar. Of course you would need to make sure that the customer would put their url in propper format when they sign up, or whatever you are doing..

Hope this helps.

Reply With Quote
  #11  
Old July 12th, 2003, 08:21 PM
dfano dfano is offline
Always Learning (I Think)
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: NYC Baby!!!!
Posts: 123 dfano User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via AIM to dfano Send a message via Yahoo to dfano
justin i was hoping you would read this, i was going to send you a private message actually, but i didnt want to bother.

_rainbow_ had some really good info though

Thanks

Dave

hey check out the site and give me some feed back
www.fs3d.com i just finished it today

Reply With Quote
  #12  
Old July 12th, 2003, 09:21 PM
nicat23's Avatar
nicat23 nicat23 is offline
Addicted to Chaos..
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jan 2003
Location: Ft. Worth, TX
Posts: 653 nicat23 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 47 m 52 sec
Reputation Power: 0
Send a message via AIM to nicat23 Send a message via Yahoo to nicat23
No worries, let me know if you need any more help

Reply With Quote
  #13  
Old July 13th, 2003, 11:37 AM
dfano dfano is offline
Always Learning (I Think)
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: NYC Baby!!!!
Posts: 123 dfano User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via AIM to dfano Send a message via Yahoo to dfano
AHHHHH

okay i thought i could do, I was wrong, dead wrong.
this what i have that works (i got with the help of Dreamweaver)

__________________________________________________ __

<html>
<head>
<title>Untitled Document</title>


<?php
$hostname_fs3d = "localhost";
$database_fs3d = "*";
$username_fs3d = "*****";
$password_fs3d = "****";
$fs3d = mysql_pconnect($hostname_fs3d, $username_fs3d, $password_fs3d) or die(mysql_error());
?>

<body>
<form name="form1" method="POST" action="<?php echo $loginFormAction; ?>">
<p>
<input name="Username" type="text" id="Username">
user name</p>
<p>
<input name="Password" type="password" id="Password">
password</p>
<p>
<input type="submit" name="Submit" value="login">
</p>

</form>


</body>
</html>

__________________________________________________ _

where the heck do i go from here.

thanks

Dave

Last edited by dfano : July 15th, 2003 at 03:12 PM.

Reply With Quote
  #14  
Old July 14th, 2003, 03:27 AM
avit avit is offline
Not Yet Perfect
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Location: Squamish, BC
Posts: 111 avit User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via ICQ to avit
Hey there,

It looks like you need to define the $loginFormAction. If you like, you can simply replace that <?php ?> block with the name of the php script that will process your login (e.g. "login.php"). That login script should contain the code you were given a few posts back by nicat23.

What about the database itself? have you built your table and put some rows into it?

Also, you don't need the database connection block on this form page. It's simply a form for collecting the info. Your second script (login.php) will handle the checking of the info. It's technically possible to have the same script check the form input, but to cut the confusion, skip that method for now--at least until you get it working.

Reply With Quote
  #15  
Old July 14th, 2003, 07:17 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
For what it's worth, if you do plan to use localized pages in some cases, you probably ought to design one such page that checks the username and password and displays custom info rather than maintaining a separate page for each user. This is of course assuming that there are common elements to all such pages.

Reply With Quote
  #16  
Old July 14th, 2003, 09:08 AM
dfano dfano is offline
Always Learning (I Think)
Dev Articles Newbie (0 - 499 posts)