PDA

View Full Version : PHP with Javascripting?


Golden_Eagle
10-03-2002, 12:57 PM
I don't know how much information your going to need for my little problem. But here goes!

This might get a little confusing! It did for me. But hopefully not for anyone who knows PHP. (Sadly, I don't!) :(

I am currently setting up a new toplist and would like to change the code that is sent out to the new sign up's. I believe I have found the coding which does this and would like to ask someone here why my new code which I have added is creating parsing errors. And if there is a solution to it.

Here is what the original code looks like -

include("data/".$ID."info.php");
$URLcode=$topURL."in.php?ID=".$ID;
$GetCodeMail='<A HREF="'.$URLcode.'"><IMG SRC="'.$voteURL.'" border="0"></A>';

And this is what I have changed it to -


include("data/".$ID."info.php");
$URLcode=$topURL."in.php?ID=".$ID;
$GetCodeMail='<A HREF="'.$URLcode.'" target="MyWindow" onClick="w=200;h=300;posx=screen.availWidth/2)-(w/2);posy=(screen.availHeight/2)-(h/2);win=window.open(this.href,this.target,'location=0,toolbar=0,resizable=1,
scrollbars=1,width='+w+',height='+h+',left='+posx+',top='+posy+',screenX='+posx+',screenY='+posy); win.focus(); return false;"><IMG SRC="'.$voteURL.'" border="0"></A>';

Code is all on the same line!

Effectively, all I have done is changed the link to have a controlled popup window and added some extra javascripting. What I'm asking I guess is - is this compatible?

If not, can anything be modified to allow for this to hapen?

Example.
All I need is this to show as the linking code

<a href="refererals link" target="MyWindow" onClick="w=200;h=300;posx = (screen.availWidth/2)-(w/2);posy = (screen.availHeight/2)-(h/2);win = window.open(this.href,this. target,'location=0,toolbar=0,resizable=1,scrollbars=1,width='+w+',height='+h+',left='+posx+',top='+p osy+',screenX='+posx+',screenY='+posy); win.focus(); return false;">;"><IMG SRC="'Vote Image Src'" border="0"></A>

Instead of this

<a href="referals link" target="_blank"><img src="Vote Image Src" border="0"></a>

Shown once sign up is completed and the user copy&pastes the code.

bcarl314
10-03-2002, 01:11 PM
Check your string concatentation.

You're beginning your string with a ' so every time you run into another ' you're closing the string. For example, you've got :

include("data/".$ID."info.php");
$URLcode=$topURL."in.php?ID=".$ID;
$GetCodeMail='<A HREF="'.$URLcode.'" target="MyWindow" onClick="w=200;h=300;posx=screen.availWidth/2)-(w/2);posy=(screen.availHeight/2)-(h/2);win=window.open(this.href,this.target,'location=0,toolbar=0,resizable=1,
scrollbars=1,width='+w+',height='+h+',left='+posx+',top='+posy+',screenX='+posx+',screenY='+posy); win.focus(); return false;"><IMG SRC="'.$voteURL.'" border="0"></A>';


This should be:

include("data/".$ID."info.php");
$URLcode=$topURL."in.php?ID=".$ID;
$GetCodeMail='<A HREF="'.$URLcode.'" target="MyWindow" onClick="w=200;h=300;posx=screen.availWidth/2)-(w/2);posy=(screen.availHeight/2)-(h/2);win=window.open(this.href,this.target,\'location=0,toolbar=0,resizable=1,
scrollbars=1,width=\ '+w+\ ',height=\ '+h+\ ',left=\ '+posx+\ ',top=\ '+posy+\ ',screenX=\ '+posx+\ ',screenY=\ '+posy); win.focus(); return false;"><IMG SRC="'.$voteURL.'" border="0"></A>';



Here I replaced all the ' in your string with \ ' . <edit>Should be a backslash with no space, but this forum escapes that, so remove the spaces from the \ ' </edit> That escapes the ' character so it doesn't end the string prematurely.

Hope this helps.

Golden_Eagle
10-03-2002, 03:09 PM
Still no joy. :(

I changed the information that is stated above, but the link stayed the same.

Here's the full original source for the members.php that is used for new sign up's.

It's too large to place on the forum and don't display properly.

So a link to a txt file that is the php here (http://www.font-factory.com/members.txt)

Please post any ideas you have on changing this script for the purpose of sign up code on this thread. Or even email it to me.

Thanks again.

mordred
10-03-2002, 03:43 PM
From your PHP example:


onClick="w=200;h=300;posx=screen.availWidth/2)-(w/2);


and what you want to have in the output


onClick="w=200;h=300;posx = (screen.availWidth/2)-(w/2);


Seems to me like you lost an opening parentheses, so that the errneous code would conjure JS errors. Fix that and report if it works for you. Also report any JS errors you receive and tell exactly what you changed and what HTML output you got. And try only putting out this variable without the rest, and if it has the desired format, include the PHP code into your application.

Golden_Eagle
10-03-2002, 04:17 PM
Very observant!

Sorry. I must admit I never noticed that. But the script that is currently uploaded is this one here (http://www.font-factory.com/members.txt).

And I have double checked that mistake on the file and it seems to be right.

Even though I have changed the code for the signing's, the actual code that gets displayed after the person has signed is still the same as it was before. There does not appear to be any JS errors being reported! :(

Here is the ACTUAL topsites URL (http://www.font-factory.com/toplist/members.php?modo=join&paso=1).

If it helps you can make a bogus name up yourself. I will be deleting them all later anyways!

Notice the errors on loadup 'AS WELL'! It never ends! :(.

Golden_Eagle
10-03-2002, 04:35 PM
Something new to develope on!

The correct Code gets mailed to the new user.

All I need now is to find out where the code is for displaying it on the screen after sign up!

As this needs to be changed to the same.

Can anyone help me find it in the members.txt above?