Wrox Programmer Forums
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 16th, 2005, 02:49 PM
Registered User
 
Join Date: Jan 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Form Submitting

Hello all! i'm new to p2p.wrox.com

i'm having a bit of trouble writing this code for a form submit! on submit the form should perform a javascript command and then load another page! the javascript part is working fine although i can't seem to get the code for the refresh right! at the moment the line looks like this:

   echo '<br><br><input type="button" value="'.$it.'" style="font-size:8px" onclick="javascript:submitit'.$ratecounter.'">';

and i want to add

header("Location: index.php?page=Voting Error");

but my syntax is always wrong and i'm getting lots of parse errors :S, can someone please write the code out for me! would be very much appreciated!

 
Old January 17th, 2005, 12:39 PM
Authorized User
 
Join Date: Jan 2005
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If I understand this right, you want to have your javascript execute and then throw the user to another page? If so, it is probably easier to use this line in your javascript at the end:

window.location = 'index.php?page=Voting Error';

Instead of using a php header.

Jeff


 
Old January 17th, 2005, 01:12 PM
Registered User
 
Join Date: Jan 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

yeah works fine except now the voting doesnt work!, hehe supposed to be Voting Successful not 'Voting Error' um..... the voting action doesnt work now .... the code looks like this....

<script language="javascript">
   function submitit'.$ratecounter.'() {
     if (document.rateform'.$ratecounter.'.rate.value=="x" ){
        alert ("You did not make a Rating");
     } else {
       document.rateform'.$ratecounter.'.submit();
       window.location = "index.php?page=Voting Successful";
     }
   }
   </script>

then later in the form the submit looks like ....

   echo '<br><br><input type="button" value="'.$it.'" style="font-size:8px" onclick="javascript:submitit'.$ratecounter.'();">' ;

any ideas?

 
Old January 17th, 2005, 01:30 PM
Authorized User
 
Join Date: Jan 2005
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You cannot have spaces in variables that are being passed through a URL. If you want to keep this, I believe you can replace a space with a '+'. I have never tried this however. If I ever need to pass a string with spaces, I use a Post. I would suggest changing your 'page' variable value to "VotingSuccessful" and make sure you modify that in your index.php file as well.

Jeff





Similar Threads
Thread Thread Starter Forum Replies Last Post
Submitting a form to a database nvillare Classic ASP Basics 2 January 27th, 2005 06:38 PM
form submitting cro_crx Pro PHP 5 January 25th, 2005 12:19 PM
Submitting a form YuliaKupina Classic ASP Basics 3 June 24th, 2004 01:52 AM
Chapter 3, submitting a form YuliaKupina BOOK: Beginning ASP 3.0 1 June 23rd, 2004 03:09 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.