Click to See Complete Forum and Search --> : Perl syntax question


bobafifi
02-17-2003, 06:07 PM
Anybody know what the Perl syntax would be to allow the characters "http://" to be the default value in the URL field on my form ( http://www.usedflutes.com/addpage.html ). Needs to be configured so that if someone chooses not to post a URL (field is optional), would strip the "http://" so that the field would post as empty?

Many thanks is advance,

-Bob

bobafifi
02-17-2003, 06:23 PM
The Perl script for the URL field to modify looks like this:

if ( $FORM{'url'} ){
print MAIL "$FORM{'url'} ";
}

jeffmott
02-19-2003, 09:23 AM
delete $FORM{url} if $FORM{url} eq 'http://';

bobafifi
02-19-2003, 09:46 AM
Thanks for trying Jeff, unfortunately the code doesn't work - 'http://' still came through...

-Bob

bobafifi
02-19-2003, 09:49 AM
http://www.usedflutes.com/addpage_URL.html

jeffmott
02-19-2003, 11:40 AM
Then either the value was not actually 'http://' or the code I gave was inserted to late in the program. If you consider the example:$FORM{url} = 'http://';
delete $FORM{url} if $FORM{url} eq 'http://';
print $FORM{url};nothing will be printed.

bobafifi
02-19-2003, 12:18 PM
Hi Jeff,

>Then either the value was not actually 'http://' or the code I gave was inserted to late >in the program.

The "http://" comes from the form http://www.usedflutes.com/addpage_URL.html so I don't think that was the problem. As for placement, I did put it up towards the beginning so not sure about that either.


>If you consider the example:


code:
------------------------------------------------------------------------
$FORM{url} = 'http://';
delete $FORM{url} if $FORM{url} eq 'http://';
print $FORM{url};
------------------------------------------------------------------------
nothing will be printed.

OK, I'll try this and see. What I'm really looking for however, is to have the "http://" only stripped if there's nothing added to it. If someone adds to the http:// , then I want that UEL value to go through. Any ideas how to set that up?

Thanks Jeff,

-Bob

bobafifi
02-19-2003, 01:05 PM
Hi Jeff,
OK - I just tried your new code, but no luck there either sorry to say. Maybe it'd help if you saw the script that I'm using?

http://www.scriptarchive.com/download.cgi?s=guestbook&c=txt&f=guestbook%2Epl

Thanks Jeff,

-Bob

jeffmott
02-19-2003, 01:48 PM
bobafifi
As for placement, I did put it up towards the beginningThat's a very broad statement and doesn't tell me a whole lot. It has to go somewhere after the parameters are parsed and before it is printed to GUEST.

What I'm really looking for however, is to have the "http://" only stripped if there's nothing added to it. If someone adds to the http:// , then I want that UEL value to go through. Any ideas how to set that up?Yeah, what I already gave you.

OK - I just tried your new code, but no luck there either sorry to sayThe new code I gave was merely an example and not meant to be the solution.

Maybe it'd help if you saw the script that I'm using? http://www.scriptarchive.com/downlo...=guestbook%2EplThe scripts available at scriptarchive.com are buggy and insecure, and should NOT be used. Even Matt no longer recommends his scripts.

bobafifi
02-19-2003, 03:41 PM
Hi Jeff,
My apologies...
I made the mistake of not slightly modifying your code so that it would be read right

(needed to change {url} to {'url'} ) and it works! :-) Thanks!

However, I've now got another problem with the code:
I use the script to send me INSERT statements for the MySQL database that I use. Since the {'url'} field is completely deleted if your code is activated, I lose the {'url'} field value for the INSERT statement and so the MySQL insert fails:

For example, this is formatted OK:


INSERT INTO `MySQL` (`Title`, `Email`, `City`, `State`, `Country`, `URL`, `Date`,
`Description`, `rid`) VALUES ('Test', 'bob', 'Seb', 'Ca', 'USA ', 'http://', 'Wednesday, February 19, 2003 ',
'Sadasd', '')

and this is not:

INSERT INTO `MySQL` (`Title`, `Email`, `City`, `State`, `Country`, `URL`, `Date`,
`Description`, `rid`) VALUES ('Test', 'bob', 'Seb', 'Ca', 'USA ', , 'Wednesday, February 19, 2003 ', 'Sadasd',
'')


Is it possible to delete the "http://" biz while still retaining the {'url'} value for the form?

Thanks again Jeff,

-Bob

jeffmott
02-19-2003, 03:58 PM
bobafifi
needed to change {url} to {'url'} ) and it worksThere must be something else that was changed because there is no difference between those two.

Is it possible to delete the "http://" biz while still retaining the {'url'} value for the form?$FORM{url} = '' if $FORM{url} eq 'http://';

bobafifi
02-19-2003, 04:53 PM
Hi Jeff,
<There must be something else that was changed because there is no difference between those two.

Well yes, I did change the "eq" to "=" (eq consisitently failed to post) and provide curly braces before and after the code. Anyhow, I just installed your last code in a similar fashion which for some reason is also deleting the url completely - regardless of what text is in the url field. Not sure what's up, but that's what's happening.

{

$FORM{'url'} = '' if $FORM{'url'} = 'http://';

}


Thanks again Jeff for your help,

-Bob

jeffmott
02-19-2003, 08:10 PM
bobafifi
Anyhow, I just installed your last code in a similar fashion which for some reason is also deleting the url completely - regardless of what text is in the url field
That's because you changed eq to =, don't do that. The curly braces don't hurt it, but don't do anything either. If it still doesn't work then upload your modified script.

bobafifi
02-20-2003, 09:07 AM
Hi Jeff,
OK, I can't figure it out...
If I leave the code 'as is,' code doesn't do anything - form processes as usual.
If I change the 'eq' to '=,' then the code works but removes the {'url'} field completely.
So anyhwow, here's the script:

http://usedflutes.com/guestbook_modified.txt

Thanks again Jeff,

-Bob

jeffmott
02-20-2003, 10:56 AM
...where's the snippet I gave you in there?

bobafifi
02-20-2003, 11:06 AM
Hi Jeff,
I didn't put your code in the script that I just up because I thought you wanted to see the original, sorry. I have tried putting it in so many different places (with the same effect regardless) that I figured there's something in conflict with it - something that's over my head to be able to detect.

Thanks again for your help Jeff,

-Bob

jeffmott
02-20-2003, 12:26 PM
I see now the problem is because the script is putting quotation marks around every value (except username). You'll first need to check if they're being quoted with single- or double quotes, and then use one of the two lines below accordingly.$FORM{url} = "''" if $FORM{url} eq "'http://'";
$FORM{url} = '""' if $FORM{url} eq '"http://"';

jeffmott
02-20-2003, 01:27 PM
Originally posted by jeffmott
You'll first need to check if they're being quoted with single- or double quotes, and then use one of the two lines below accordingly.$FORM{url} = "''" if $FORM{url} eq "'http://'";
$FORM{url} = '""' if $FORM{url} eq '"http://"';
Scratch that, this is better.
$FORM{url} = $dbh->quote('') if $FORM{url} eq $dbh->quote('http://');

bobafifi
02-20-2003, 01:35 PM
That works! Thanks! :-)
I used the first of the new codes you gave and no problems (yippie!). Had just finished modifying the script and uploading it and was about to reply to you when I got your second post...
I'll check that code out a little later today (gotta get some lunch...).

Thanks once again Jeff for all your help,

-Bob

celebguy_dv
03-04-2003, 01:01 AM
http://banners.dollarmachine.com/pic/2014000/hal001.gif (http://www.kinkyceleb.com/1261795520)