hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : some code help
Reply

Forum Jump

some code help

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 09-09-2004, 12:02 PM
BizB BizB is offline
Web Hosting Evangelist
 
Join Date: Jul 2003
Posts: 527

some code help


hi,
i want to make a script that does the following

some one puts a code in there pages like this

<SCRIPT language="JavaScript" src="http://mysite.com/script.php?id=userid"></SCRIPT>

which would load a java script with that userid inside it
like
win2=window.open ('http://mysite.com/script2.php?id=userid','_blank','top=1,left=1,width=550,height=300,buttons=1,scrollbars=1,location=1,menubar=1,resizable=1,status=1,directories=1,tool bar=1'),win2.blur(),window.focus();

so the php script will echo out the java script and add userid inside it

any one knows how to do this ?

the end reselt the user with this code
<SCRIPT language="JavaScript" src="http://mysite.com/script.php?id=userid"></SCRIPT>
in there page will be converted to
<SCRIPT language="JavaScript" src="my java script inside the script.php with userid inside it"></SCRIPT>
most important that the userid changes for each member
thanks



Sponsored Links
  #2  
Old 09-09-2004, 03:42 PM
Saeven Saeven is offline
Web Hosting Master
 
Join Date: Aug 2002
Location: Canada
Posts: 647
That's kind of an off approach.

What you want to do is define your page with a link that 'onclick' calls your window open script.

you can't do this with javascript alone. You'll need a technology like PHP.

1. Build an HTML page and replace userid with %USERID% - ni our example it will be template.htm

2. Build a PHP page that has available the user's id, in a SESSION variable, or POST - anything you like. If it were stored in a SESSION array it would look like this:

Code:
<?
session_name( 'somename' );
session_start();

$fp = str_replace( '%USERID%', $_SESSION['userid'], implode( '', file( 'template.html' ) );

echo $fp;
?>
this way, the php file reads the unparsed template, replaces %USERID% with the actual user id, and then echoes the result.

HTH
Alex

  #3  
Old 09-09-2004, 04:33 PM
BizB BizB is offline
Web Hosting Evangelist
 
Join Date: Jul 2003
Posts: 527
how would the php script know what is userid is ?
this code will change like
<SCRIPT language="JavaScript" src="http://mysite.com/script.php?id=site1"></SCRIPT>

<SCRIPT language="JavaScript" src="http://mysite.com/script.php?id=site2"></SCRIPT>

the php script must think the http://mysite.com/script.php?id=%USERID% and then use it in the templete.html

Sponsored Links
  #4  
Old 09-10-2004, 04:21 AM
BizB BizB is offline
Web Hosting Evangelist
 
Join Date: Jul 2003
Posts: 527
up up up and away

  #5  
Old 09-10-2004, 12:07 PM
BizB BizB is offline
Web Hosting Evangelist
 
Join Date: Jul 2003
Posts: 527
any one home ?
is there any other site which has more programers ?
its a simple idear
a code in one page that calls a php script
like
<SCRIPT language="JavaScript" src="http://mysite.com/script.php?id=site2"></SCRIPT>

and this php script in turn gets the userid from the code "id=" and then prints a java code with that same userid

like
win2=window.open ('http://mysite.com/script2.php? id=userid','_blank','top=1,left=1,width=550,height=300'),win2
.blur(),window.focus();

and because the php script was called between <script> and </script> it will be like the original code was

<SCRIPT language="JavaScript">
win2=window.open ('http://mysite.com/script2.php? id=userid','_blank','top=1,left=1,width=550,height=300'),win2
.blur(),window.focus();
</SCRIPT>

Reply

Related posts from TheWhir.com
Title Type Date Posted
Web Host Code Spaces Closes Shop After Hacker Deletes Customer Data Web Hosting News 2014-06-19 16:34:41
Web Hosting Sales and Promos Roundup - May 2, 2014 Web Hosting News 2014-05-23 16:54:17
Web Hosting Sales and Promos Roundup – April 11, 2014 Web Hosting News 2014-05-23 15:42:21
Free WHD.global Registration with the WHIR Coupon Code Blog 2014-01-30 13:24:20
Web Hosting Sales and Promos Roundup - October 4, 2013 Web Hosting News 2014-05-23 15:42:45


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

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 On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?