Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 05-18-2009, 03:56 PM PHP help please!
kline11's Avatar
SearchBliss Web Tools

Posts: 1,788
Name: John
Location: USA
Trades: 0
I know ASP, not PHP.

That being said, I have a PHP script that works fine after I post user input, however, the script runs when the page loads before the user input can be submitted...so I get an error. How do I prevent the code from running before the user input is posted?

Thank you to anyone who can help.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
kline11 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-18-2009, 04:47 PM Re: PHP help please!
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Without seeing the page code, no certainty, but you probably have the form and the processing code in the same page.

In that case, you must enclose the processing code into a block to activate it only when the form is posted

PHP Code:
<?php
if sizeof($_POST)>0{
  
//...handle the post processing here
}

//put the page code here
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 05-18-2009, 04:48 PM Re: PHP help please!
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
Test for whether user input exists and execute the desired code block only if the condition is met. In pseudo code:

Code:
IF {user has posted data}
  {process user data}
END IF
{show page content}
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 05-18-2009, 05:41 PM Re: PHP help please!
kline11's Avatar
SearchBliss Web Tools

Posts: 1,788
Name: John
Location: USA
Trades: 0
I edited the post because your script worked (kind of). Thanks tripy!
I used
Code:
if(isset($_POST["curl"])>0){ 
  //...handle the post processing here
Is this eceptable, or is "isset" uneeded? Thanks again!
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Last edited by kline11; 05-18-2009 at 06:01 PM..
kline11 is offline
Reply With Quote
View Public Profile
 
Old 05-18-2009, 06:16 PM Re: PHP help please!
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
Actually I think the > 0 is uneeded. isset returns a boolean so comparing it with 0 is unnecessary. You can simplify your condition like this:
PHP Code:
if(isset($_POST['curl']))
{
.
.
.

__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is offline
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 05-18-2009, 10:36 PM Re: PHP help please!
kline11's Avatar
SearchBliss Web Tools

Posts: 1,788
Name: John
Location: USA
Trades: 0
Quote:
Originally Posted by NullPointer View Post
Actually I think the > 0 is uneeded. isset returns a boolean so comparing it with 0 is unnecessary. You can simplify your condition like this:
PHP Code:
if(isset($_POST['curl']))
{
.
.
.

Thanks! This makes sense and works perfectly. I hate useless/redundant code...so thank you.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
kline11 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to PHP help please!
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.32825 seconds with 12 queries