Jump to content

Recommended Posts

Hey,

 

I have the following piece of code, please could someone tell me if they can see any problems with it? Will echo "table code"; work in the case'1' ?

 

Really need to get this working!! :)

 

Thanks in advance

 

<body>
<?php
$thisPage = ( isset($_POST['showpage']) and ctype_digit($_POST['showpage'])? $_POST['showpage'] : '1' );
   
if ( $thisPage == '7' ) {
  // This is the last page - show/process results here
  foreach( $_POST as $name => $value ) {
    print "$name - $value<br>";
    echo "Your quote was generated successfully. It has been sent to Tax Monitor and one of our representatives will contact you with further details.";
    
    
}
  
else {
  // Other page - Create form and hidden inputs
  print '<form method="post" action="'.$_SERVER['php_SELF'].'">';
  
  foreach ( $_POST as $name => $value ) {
    print '<input type="hidden" name="'.$name.'" value="'.$value.'">';
  
  switch ( $thisPage ) {


  case '6':
    print '<input type="hidden" name="showpage" value="5">';
    // Put PAGE 4 inputs here
        // END PAGE 6
    break;

  case '5':
    print '<input type="hidden" name="showpage" value="5">';
    // Put PAGE 4 inputs here
        // END PAGE 5
    break;
  
  case '4':
    print '<input type="hidden" name="showpage" value="5">';
    // Put PAGE 4 inputs here
        // END PAGE 4
    break;
  
  case '3':
    print '<input type="hidden" name="showpage" value="4">';
    // Put PAGE 3 inputs here
        // END PAGE 3
    break;
  
  case '2':
    print '<input type="hidden" name="showpage" value="3">';
    // Put PAGE 2 inputs here
    
    // END PAGE 2
    
    
    break;
  
  case '1':
  default:
    print '<input type="hidden" name="showpage" value="2">';

// Start PG 1
echo "<table width="100%" border="0" cellpadding="0" cellspacing="0" class="tableform">
  <tr>
    <td colspan="3" class="tableheader">Contact Details</td>
  </tr>
  <tr>
    <td colspan="3"> </td>
  </tr>
  <tr>
    <td colspan="3"><img src="../imgs/spacer.gif" width="57" height="4" /></td>
  </tr>
  <tr>
    <td width="5%" class="formtext"><img src="../imgs/dialup/bullet.gif" width="10" height="10" /></td>
    <td width="34%" class="formtext">Full Name: </td>
    <td width="61%"><input type="text" name="textfield" class="textbox"/></td>
  </tr>
  <tr>
    <td class="formtext"><img src="../imgs/dialup/bullet.gif" width="10" height="10" /></td>
    <td class="formtext">Email Address: </td>
    <td><input name="textfield2" type="text" class="textbox" /></td>
  </tr>
  <tr>
    <td class="formtext"><img src="../imgs/dialup/bullet.gif" width="10" height="10" /></td>
    <td class="formtext">Contact Number: </td>
    <td><input name="textfield3" type="text" class="textbox" /></td>
  </tr>
  <tr>
    <td class="formtext"><img src="../imgs/dialup/bullet.gif" width="10" height="10" /></td>
    <td class="formtext">Company:</td>
    <td><input name="textfield4" type="text" class="textbox" /></td>
  </tr>
  <tr>
    <td> </td>
    <td height="18"><img src="../imgs/spacer.gif" width="57" height="2" /></td>
    <td> </td>
  </tr>
</table>";
// END PG 1


    break;
  }
  print '</form>';
}
?>
</body>

Link to comment
https://forums.phpfreaks.com/topic/82930-will-this-piece-of-code-function-alright/
Share on other sites

Ok ive even simplified it, and it still wont work for me when I load the page.. it just shows a blank page as you can see here..

 

http://taxmon.designrobot.co.za/test.php

 

Im really desperate to get this code working, really would appreciate any advice

 

 

 

<body> 
<?php 
$thisPage = ( isset($_POST['showpage']) and ctype_digit($_POST['showpage'])? $_POST['showpage'] : '1' ); 
   
if ( $thisPage == '7' ) { 
  // This is the last page - show/process results here 
  foreach( $_POST as $name => $value ) { 
    print "$name - $value<br>";


} 
  
else { 
  // Other page - Create form and hidden inputs 
  print '<form method="post" action="'.$_SERVER['php_SELF'].'">'; 
  
  foreach ( $_POST as $name => $value ) { 
    print '<input type="hidden" name="'.$name.'" value="'.$value.'">'; 
  
  switch ( $thisPage ) { 


  case '6':
    print '<input type="hidden" name="showpage" value="7">'; 
    // Put PAGE 4 inputs here 
	// END PAGE 6
    break; 

  case '5': 
    print '<input type="hidden" name="showpage" value="6">'; 
    // Put PAGE 4 inputs here 
	// END PAGE 5
    break; 
  
  case '4': 
    print '<input type="hidden" name="showpage" value="5">'; 
    // Put PAGE 4 inputs here 
	// END PAGE 4
    break; 
  
  case '3': 
    print '<input type="hidden" name="showpage" value="4">'; 
    // Put PAGE 3 inputs here 
	// END PAGE 3
    break; 
  
  case '2': 
    print '<input type="hidden" name="showpage" value="3">'; 
    // Put PAGE 2 inputs here 

// END PAGE 2


    break; 
  
  case '1': 
  default: 
    print '<input type="hidden" name="showpage" value="2">'; 

// Start PG 1
print "hello";
// END PG 1


    break; 
  } 
  print '</form>'; 
} 
?> 
</body> 

 

 

Blank php pages are usually the result of fatal parse or fatal runtime errors. I recommend turning on full php error reporting in php.ini or a .htaccess file to get php to help you find out what is happening.

  • 1 month later...

You don't have to remove them, but you can...  If there is only one line of code inside the loop the { and } are unnecessary.  More than one line and you need them.  What you currently have closes the loops, but you are not closing the if/else statement.  Try this:

 

<?php 
$thisPage = ( isset($_POST['showpage']) and ctype_digit($_POST['showpage'])? $_POST['showpage'] : '1' ); 
   
if ( $thisPage == '7' ) { 
  // This is the last page - show/process results here 
  foreach( $_POST as $name => $value ) { 
    print "$name - $value<br>";
  }

} 
  
else { 
  // Other page - Create form and hidden inputs 
  print '<form method="post" action="'.$_SERVER['php_SELF'].'">'; 
  
  foreach ( $_POST as $name => $value ) { 
    print '<input type="hidden" name="'.$name.'" value="'.$value.'">'; 
  }
  
  switch ( $thisPage ) { 


  case '6':
    print '<input type="hidden" name="showpage" value="7">'; 
    // Put PAGE 4 inputs here 
	// END PAGE 6
    break; 

  case '5': 
    print '<input type="hidden" name="showpage" value="6">'; 
    // Put PAGE 4 inputs here 
	// END PAGE 5
    break; 
  
  case '4': 
    print '<input type="hidden" name="showpage" value="5">'; 
    // Put PAGE 4 inputs here 
	// END PAGE 4
    break; 
  
  case '3': 
    print '<input type="hidden" name="showpage" value="4">'; 
    // Put PAGE 3 inputs here 
	// END PAGE 3
    break; 
  
  case '2': 
    print '<input type="hidden" name="showpage" value="3">'; 
    // Put PAGE 2 inputs here 

// END PAGE 2


    break; 
  
  case '1': 
  default: 
    print '<input type="hidden" name="showpage" value="2">'; 

// Start PG 1
print "hello";
// END PG 1


    break; 
  } 
  print '</form>'; 
} 
?>

 

Theo

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.