Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-22-2011, 10:07 PM   PM User | #1
Chris-2k
Regular Coder

 
Join Date: May 2011
Posts: 303
Thanks: 29
Thanked 0 Times in 0 Posts
Chris-2k is an unknown quantity at this point
Limit Form Submission P2

As i cudn't post in my old thread, cos vBull**** suckzors big time lol, im making this thread for help:

kk ive got this code:

PHP Code:
<?php
if($_POST['submit']{ 
          
          
$formid $_POST['submitdownloads'//standard variables are easier to work with
                
if(isset($_COOKIE[$formid]){ 
                    if(
$_COOKIE[$formid] >= 2){ 
                        echo(
"Thanks for submitting your downloads, you have now reached the limit");
                        } else {
                    
$_COOKIE[$formid] += 1;
                        echo(
"Submitting data...");
                        } else { 
                    
setcookie($formid186400); //name formid, value 1, expires in 86400 seconds
    

}
?>
and im getting this error:

Code:
Parse error: syntax error, unexpected T_IF in /home/chris2009/xtremeddl.net/submit.php on line 90
Im tryna make da form initialy, per session be able to be submitted 5x....

any help?
Chris-2k is offline   Reply With Quote
Old 05-22-2011, 10:39 PM   PM User | #2
djh101
Regular Coder

 
djh101's Avatar
 
Join Date: May 2009
Location: Santa Clarita
Posts: 603
Thanks: 48
Thanked 63 Times in 63 Posts
djh101 is an unknown quantity at this point
http://www.rosettastone.com/spring5p...FRNrgwodvW7LTg

Oh, and there's no ; after your $formid line.
__________________
"Yeah science!"
Online Science Tools
djh101 is offline   Reply With Quote
Old 05-22-2011, 11:12 PM   PM User | #3
Chris-2k
Regular Coder

 
Join Date: May 2011
Posts: 303
Thanks: 29
Thanked 0 Times in 0 Posts
Chris-2k is an unknown quantity at this point
Sorry about the language...

Fixed the ; here:
PHP Code:
<?php
if($_POST['submit']{ 
          
          
$formid $_POST['submitdownloads']; //standard variables are easier to work with
                
if(isset($_COOKIE[$formid]){ 
                    if(
$_COOKIE[$formid] >= 2){ 
                        echo(
"Thanks for submitting your downloads, you have now reached the limit");
                        } else {
                    
$_COOKIE[$formid] += 1;
                        echo(
"Submitting data...");
                        } else { 
                    
setcookie($formid186400); //name formid, value 1, expires in 86400 seconds
    

}
?>
now got this error:
Code:
Parse error: syntax error, unexpected ';' in /home/chris2009/xtremeddl.net/submit.php on line 89
Edit: here's my whole form:

PHP Code:
       <form action="" method="post">

<?php
if($_POST['submit']{ 
          
          
$formid $_POST['submitdownloads']; //standard variables are easier to work with
                
if(isset($_COOKIE[$formid]){ 
                    if(
$_COOKIE[$formid] >= 2){ 
                        echo(
"Thanks for submitting your downloads, you have now reached the limit");
                        } else {
                    
$_COOKIE[$formid] += 1;
                        echo(
"Submitting data...");
                        } else { 
                    
setcookie($formid186400); //name formid, value 1, expires in 86400 seconds
    

}
?>


        <?php
        
for($i=1;$i<=10;$i++) {
        
?>

        <div>
        <input type="text" class="inputbox" name="title[]" id="dt1" cols="80" />
        <input type="text" class="inputbox" name="url[]" id="du1" />
        <select name="type[]" class="inputbox smallbox" id="se1">
        <?php
        
foreach($core->allowed_types as $at) {
        echo 
'<option value="'.$at.'">'.$at.'</option>';
        }
        
?>
        </select></div>
        <?php
        
}
        
?>

        <div>Site Name: <input type="text" class="inputbox" name="sname" id="zname"/>
        Site URL: <input type="text" class="inputbox" name="surl" id="zurl"/><br />
        Email: <input type="text" class="inputbox" name="email" id="zemail"/>
        <input type="submit" value="Submit Downloads" /></div>

        <div><?=$core->error?>
        <br /><?=$sub_success?></div>
        </form>
do u have msn to chat?

Last edited by Chris-2k; 05-22-2011 at 11:19 PM..
Chris-2k is offline   Reply With Quote
Old 05-22-2011, 11:50 PM   PM User | #4
djh101
Regular Coder

 
djh101's Avatar
 
Join Date: May 2009
Location: Santa Clarita
Posts: 603
Thanks: 48
Thanked 63 Times in 63 Posts
djh101 is an unknown quantity at this point
You are also missing a ) after your first if statement. "if($_POST['submit']){"

Just work on weeding out all instances that are missing characters. That should be it, but if you get any more errors, go to the line that the error is on and it shouldn't be too hard to find what's wrong.

EDIT: A few more errors
1. "if(isset($_COOKIE[$formid])){ "
2. echo "Thanks for submitting your downloads, you have now reached the limit" ; //echoed statements do not need to be surrounded in ()
__________________
"Yeah science!"
Online Science Tools

Last edited by djh101; 05-22-2011 at 11:53 PM..
djh101 is offline   Reply With Quote
Users who have thanked djh101 for this post:
Chris-2k (05-23-2011)
Old 05-22-2011, 11:54 PM   PM User | #5
tangoforce
Senior Coder

 
tangoforce's Avatar
 
Join Date: Feb 2011
Location: Your Monitor
Posts: 3,516
Thanks: 45
Thanked 440 Times in 429 Posts
tangoforce will become famous soon enoughtangoforce will become famous soon enough
Don't use if (isset($_POST['submit'])) because internet explorer has a but and doesn't always send the submit button value. You should test for other data in the form instead.

Also can I perhaps interest you in the 2nd link in my signature? - You might find it useful for the future
__________________
Please wrap your code in [php] tags. It is a sticky topic and it HELPS us to HELP YOU!
TIP: Coding styles and $end errors :::::::::: TIP: Warning: Cannot modify header information - headers already sent :::::::::: TIP: Quotes / Parse error: syntax error, unexpected T_..
PHP Code:
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value. 
Explanation: The IE if(isset($_POST['submit'])) bug explained.

Last edited by tangoforce; 05-23-2011 at 12:16 AM..
tangoforce is offline   Reply With Quote
Old 05-23-2011, 12:27 AM   PM User | #6
Chris-2k
Regular Coder

 
Join Date: May 2011
Posts: 303
Thanks: 29
Thanked 0 Times in 0 Posts
Chris-2k is an unknown quantity at this point
corrected all errors now,

PHP Code:
<?php
if($_POST['submit']){ 
          
          
$formid $_POST['submitdownloads']; //standard variables are easier to work with
                
if(isset($_COOKIE[$formid])
                    {
                    if(
$_COOKIE[$formid]) >= 2){ 
                        echo 
"Thanks for submitting your downloads, you have now reached the limit";
                        } else {
                    
$_COOKIE[$formid] += 1;
                        echo 
"Submitting data...";
                        } else { 
                    
setcookie($formid186400); //name formid, value 1, expires in 86400 seconds
    

}
?>
now got:

Code:
Parse error: syntax error, unexpected '{' in /home/chris2009/xtremeddl.net/submit.php on line 91
Chris-2k is offline   Reply With Quote
Old 05-23-2011, 12:57 AM   PM User | #7
djh101
Regular Coder

 
djh101's Avatar
 
Join Date: May 2009
Location: Santa Clarita
Posts: 603
Thanks: 48
Thanked 63 Times in 63 Posts
djh101 is an unknown quantity at this point
Refer to my last post. if(isset($_COOKIE[$formid]) is still missing a ). You have two opening parenthesis (one before isset and one before $_COOKIE) and only one ending parenthesis.
__________________
"Yeah science!"
Online Science Tools
djh101 is offline   Reply With Quote
Old 05-23-2011, 01:24 AM   PM User | #8
tangoforce
Senior Coder

 
tangoforce's Avatar
 
Join Date: Feb 2011
Location: Your Monitor
Posts: 3,516
Thanks: 45
Thanked 440 Times in 429 Posts
tangoforce will become famous soon enoughtangoforce will become famous soon enough
There is also one closing parenthesis too many on this line - 2 closing and 1 opening:

if($_COOKIE[$formid]) >= 2){
__________________
Please wrap your code in [php] tags. It is a sticky topic and it HELPS us to HELP YOU!
TIP: Coding styles and $end errors :::::::::: TIP: Warning: Cannot modify header information - headers already sent :::::::::: TIP: Quotes / Parse error: syntax error, unexpected T_..
PHP Code:
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value. 
Explanation: The IE if(isset($_POST['submit'])) bug explained.
tangoforce is offline   Reply With Quote
Old 05-23-2011, 02:02 AM   PM User | #9
djh101
Regular Coder

 
djh101's Avatar
 
Join Date: May 2009
Location: Santa Clarita
Posts: 603
Thanks: 48
Thanked 63 Times in 63 Posts
djh101 is an unknown quantity at this point
Ah yes, you added the ) after the wrong $_COOKIE[$formid].
__________________
"Yeah science!"
Online Science Tools
djh101 is offline   Reply With Quote
Old 05-23-2011, 02:43 PM   PM User | #10
Chris-2k
Regular Coder

 
Join Date: May 2011
Posts: 303
Thanks: 29
Thanked 0 Times in 0 Posts
Chris-2k is an unknown quantity at this point
hi,

fixed:

PHP Code:
<?php
if($_POST['submit']){ 
          
          
$formid $_POST['submitdownloads']; //standard variables are easier to work with
                
if(isset($_COOKIE[$formid])) { 
                    if(
$_COOKIE[$formid]) >= 
                        echo 
"Thanks for submitting your downloads, you have now reached the limit";
                        } else {
                    
$_COOKIE[$formid] += 1;
                        echo 
"Submitting data...";
                        } else { 
                    
setcookie($formid186400); //name formid, value 1, expires in 86400 seconds
    

}
?>
now im getting:

Code:
Parse error: syntax error, unexpected T_IS_GREATER_OR_EQUAL in /home/chris2009/xtremeddl.net/submit.php on line 91
i dunno what this means, help?

As you might guess, I'm definitely not an avid PHPer :-)

Thanks for your help so far! I hope we can get this working!

Last edited by Chris-2k; 05-23-2011 at 03:09 PM..
Chris-2k is offline   Reply With Quote
Old 05-23-2011, 05:19 PM   PM User | #11
tangoforce
Senior Coder

 
tangoforce's Avatar
 
Join Date: Feb 2011
Location: Your Monitor
Posts: 3,516
Thanks: 45
Thanked 440 Times in 429 Posts
tangoforce will become famous soon enoughtangoforce will become famous soon enough
Change:
PHP Code:
($_COOKIE[$formid]) >= 
to:
PHP Code:
($_COOKIE[$formid] >= 
__________________
Please wrap your code in [php] tags. It is a sticky topic and it HELPS us to HELP YOU!
TIP: Coding styles and $end errors :::::::::: TIP: Warning: Cannot modify header information - headers already sent :::::::::: TIP: Quotes / Parse error: syntax error, unexpected T_..
PHP Code:
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value. 
Explanation: The IE if(isset($_POST['submit'])) bug explained.
tangoforce is offline   Reply With Quote
Old 05-23-2011, 07:09 PM   PM User | #12
Chris-2k
Regular Coder

 
Join Date: May 2011
Posts: 303
Thanks: 29
Thanked 0 Times in 0 Posts
Chris-2k is an unknown quantity at this point
ok thx, done:

PHP Code:
<?php
if($_POST['submit']){ 
          
          
$formid $_POST['submitdownloads']; //standard variables are easier to work with
                
if(isset($_COOKIE[$formid])) { 
                    if(
$_COOKIE[$formid] >= 2) { 
                        echo 
"Thanks for submitting your downloads, you have now reached the limit";
                        } else {
                    
$_COOKIE[$formid] += 1;
                        echo 
"Submitting data...";
                        } else { 
                    
setcookie($formid186400); //name formid, value 1, expires in 86400 seconds
    

}
?>
error:

Code:
Parse error: syntax error, unexpected T_ELSE in /home/chris2009/xtremeddl.net/submit.php on line 96
ty indeed.
Chris-2k is offline   Reply With Quote
Old 05-23-2011, 10:53 PM   PM User | #13
djh101
Regular Coder

 
djh101's Avatar
 
Join Date: May 2009
Location: Santa Clarita
Posts: 603
Thanks: 48
Thanked 63 Times in 63 Posts
djh101 is an unknown quantity at this point
You cannot have an else statement after an else statement. I don't think I need to explain why.
__________________
"Yeah science!"
Online Science Tools
djh101 is offline   Reply With Quote
Old 05-23-2011, 11:14 PM   PM User | #14
tangoforce
Senior Coder

 
tangoforce's Avatar
 
Join Date: Feb 2011
Location: Your Monitor
Posts: 3,516
Thanks: 45
Thanked 440 Times in 429 Posts
tangoforce will become famous soon enoughtangoforce will become famous soon enough
Along with having 2 else's, you also have a { too many. For the else problem you have two options: elseif or switch().

I've already recommended you take a look at the second link in my signature about coding styles. You chose to ignore that so i won't be assisting you to find the additional { as apparently you are above my help.
__________________
Please wrap your code in [php] tags. It is a sticky topic and it HELPS us to HELP YOU!
TIP: Coding styles and $end errors :::::::::: TIP: Warning: Cannot modify header information - headers already sent :::::::::: TIP: Quotes / Parse error: syntax error, unexpected T_..
PHP Code:
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value. 
Explanation: The IE if(isset($_POST['submit'])) bug explained.

Last edited by tangoforce; 05-23-2011 at 11:18 PM..
tangoforce is offline   Reply With Quote
Old 05-23-2011, 11:31 PM   PM User | #15
Chris-2k
Regular Coder

 
Join Date: May 2011
Posts: 303
Thanks: 29
Thanked 0 Times in 0 Posts
Chris-2k is an unknown quantity at this point
Okay ty, now i end the page like:

PHP Code:
<?php

?>
and get this error:

Code:
Parse error: syntax error, unexpected $end in /home/chris2009/xtremeddl.net/submit.php on line 185
thats just how the Wcddl script ends pages.. any ideas?
Chris-2k is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 01:29 AM.


Advertisement
Log in to turn off these ads.