Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 17th, 2005, 10:20 AM
danubian@hotmail.com
Guest
 
Posts: n/a
Default How to transfer variables from a .php script to an .html page that will display the results.

Hi,

I'm a newbie in php/mysql programming,really am.
I'm working on a web-site that allows registration and posterior
logging in. Already registered user logs in with valid username and
password. Username and password are validated against a MySQL database
of personal data that contains these fields among others.
This is done by means of a PHP script that redirects to a "page2.html"
(if user and password non-existent) OR it redirects to a
"page3.html",if username and password exist and match in the database.
Following is part of the code:

<?php
function RedirectURL($url)
{ // This calls javascript
$redir = "<script language=\"javascript\">location.href=\"$url\"</script>\n";
return $redir;
}
?> // got this function from the groups. thanks.

<?php
..
..
..
$query = "SELECT password FROM all_pers_data WHERE username =
'$loginID' ";

$result = mysql_query($query) or die
(RedirectURL('http://xxx.xxx.xxx.xxx:XXXX/ / /page2.html'));
$numentries = mysql_numrows($result); //Numero de filas
returned. mysql_close($link);

$correct_username = $loginID;
$correct_password = mysql_result($result,0,"password"); //assumming
there is only one match...
if (strcasecmp($correct_username,$loginID) ||
strcasecmp($correct_password,$loginPW) ) {
die(RedirectURL('http://xxx.xxx.xxx.xxx:XXXX/ / /page2.html'));
//loginID or password that do not match
}
else {
die(RedirectURL('http://xxx.xxx.xxx.xxx:XXXX/ /
/page3.html'));//ASSERT, print out info in .html page.
}
..
..
..

?>

My question is: how can I transfer the variable "$result" from my PHP
to the .html pages, so that I'm able to print out the info for the
existent user through page3.html. In other words, i would like to
re-use "$result" from the php/mysql query; this, in order to display
information about the successfully logged in user.

Any help or suggestions i will appreciate a lot. Thanks.

Ivan
  #2  
Old July 17th, 2005, 10:20 AM
Grant Wagner
Guest
 
Posts: n/a
Default Re: How to transfer variables from a .php script to an .html page thatwill display the results.

danubian@hotmail.com wrote:
[color=blue]
> My question is: how can I transfer the variable "$result" from my PHP
> to the .html pages, so that I'm able to print out the info for the
> existent user through page3.html. In other words, i would like to
> re-use "$result" from the php/mysql query; this, in order to display
> information about the successfully logged in user.
>
> Any help or suggestions i will appreciate a lot. Thanks.[/color]

<url: http://jibbering.com/faq/#FAQ4_18 />

--
Grant Wagner <gwagner@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq

  #3  
Old July 17th, 2005, 10:21 AM
Pedro Graca
Guest
 
Posts: n/a
Default Re: How to transfer variables from a .php script to an .html page that will display the results.

["Followup-To:" header set to comp.lang.php.]
danubian@hotmail.com wrote:
[snip][color=blue]
> My question is: how can I transfer the variable "$result" from my PHP
> to the .html pages, so that I'm able to print out the info for the
> existent user through page3.html. In other words, i would like to
> re-use "$result" from the php/mysql query; this, in order to display
> information about the successfully logged in user.
>
> Any help or suggestions i will appreciate a lot. Thanks.[/color]

Use session variables: http://www.php.net/session

When you know the $result save it in a session variable

$_SESSION['SQLResult'] = $result;

and, afterwards, when you need the same result use the value saved in
the session variable

echo 'Saved result is: ', $_SESSION['SQLResult'];

Don't forget to start the session support in *every* page that uses the
$_SESSION array
--
USENET would be a better place if everybody read: | to mail me: simply |
http://www.catb.org/~esr/faqs/smart-questions.html | "reply" to this post, |
http://www.netmeister.org/news/learn2quote2.html | *NO* MIME, plain text |
http://www.expita.com/nomime.html | and *NO* attachments. |
  #4  
Old July 17th, 2005, 10:21 AM
Michael Fesser
Guest
 
Posts: n/a
Default Re: How to transfer variables from a .php script to an .html page that will display the results.

.oO(danubian@hotmail.com)
[color=blue]
> function RedirectURL($url)
> { // This calls javascript
> $redir = "<script language=\"javascript\">location.href=\"$url\"</script>\n";
> return $redir;
> }[/color]

header("Location: $url");

http://www.php.net/header

Micha
  #5  
Old July 17th, 2005, 10:23 AM
Geoff Berrow
Guest
 
Posts: n/a
Default Re: How to transfer variables from a .php script to an .html page that will display the results.

I noticed that Message-ID:
<slrnco28a3.knd.hexkid@ID-203069.user.uni-berlin.de> from Pedro Graca
contained the following:
[color=blue][color=green]
>> My question is: how can I transfer the variable "$result" from my PHP
>> to the .html pages, so that I'm able to print out the info for the
>> existent user through page3.html. In other words, i would like to
>> re-use "$result" from the php/mysql query; this, in order to display
>> information about the successfully logged in user.
>>
>> Any help or suggestions i will appreciate a lot. Thanks.[/color]
>
>Use session variables: http://www.php.net/session[/color]

But if the pages need to have a .php extension.
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles