500 Internal Server Error

When calling another .php file with header (‘xx.php’); i get into this error. The moment I uncomment the line the rest of the script works … really dont know what I should do. Cant go on with my work …

Who can help?

[code]<?php
session_start();
$booknr = $_POST[‘booknr’];
$regnr = $_POST[‘regnum’];

/*
$_SESSION['pname'] = $_POST['pname'];
$_SESSION['regkey'] = $_POST['regkey'];
*/

if($_POST['edit']){
	switch ($_POST['edit']){
            
		    case  empty ($_POST['pname']) 
		    || empty ($_POST['fname'])
		    || empty ($_POST['company'])
		    || empty ($_POST['email'])
		    || empty ($_POST['arrive'])
		    || empty ($_POST['depart'])
		    || empty ($_POST['checkin'])
		    || empty ($_POST['checkout'])
		    :
		    
		    
		    $er_msg = "<br> Error: Please fill out all fields!\" ";
		    $er_msg.= '<br><br>';
		     
		    $er_msg.= '<form id="edit_return" method="post" action="edit_booking.php">
		    		   <label for="bookingnumber">Return:</label>
                       <input type="text" name="booknr" value="'.$regnr.'" id="booknr" />
                       <input type="submit" name="subbook" value="login" /> 		
                       </form>	';  //offers a field (automatic registry-num - just to return where you came from)
                      
		    
		    break;	
		    
		   
		    case ! empty ($_POST['pname']) //simplified for error-debugging //
	        :
		    header ('thanks.php');
		    break;	
		    
		    } 

   }

?>

xxx REGISTRATION PORTAL <!--
body { font-size: 65%;}
body, ul, li { margin: 0; padding: 0;}
li { list-style: none;}
.tab_01, th, td { border-spacing: 0px; padding: 0px;  }
#err_message {color: #b71111; font-weight: normal; font-style: italic; }


.edform_main {position: relative; left: 40px; font-family: Arial, sans-serif; font-size: 12px; color: #616161; top: 6px; }
.edform { height: 14px;  position: absolute; left: 120px; width: 240px;  }
.line { margin-bottom: 11px; color: black;  }
.radioblock1 { margin-top: 22px; margin-bottom: 30px; width: 400px; }
.radioblock2 { margin-top: 0px; margin-bottom: 2px; width: 400px; }
#buttonline  { clear: both; height: 40px; margin-top: 28px; padding-left: 217px; width: 155px; }
#buttonline div {float: left; }
#reg_key { position: relative; top: 10px; left: 320px; font-size: 10px; color: gray; width: 20px; }
  #reg_key input {width: 40px; visibility: hidden }
#reg_num { position: relative; top: 10px; left: 260px; font-size: 10px; color: gray; width: 20px; display: none; }

–>

	 <div id="wrap_main">
	        <div id="background"></div>
	        <div id="wrap-data">
	        
	        <form id="booking_edit" method="post" action="edit_booking.php">
				<label for="bookingnumber">Buchungsnummer:</label>
				<input type="text" name="booknr" value="" id="booknr" />
				<input type="submit" name="subbook" value="login" /> 		
			</form>	
	        
  
	         <p><h3>  Edit, delete or extend your booking (Nr.: <?php echo $booknr ?> )</h3> </p>
                 Should you have any additional questions, please do not hesitate to contact us:
                 <a href= "mailto:[email protected]">[email protected]</a>
                 <br><br>	Your Team<p></p>




       <?php
        $regnr_mail = $_SESSION['booknr'];
                
        $server = 'localhost';
		$benutzer = 'db263710';
		$passwort = '7vRgHLq';
		$datenbank = 'db263710';
		
		$db_handle = mysql_connect($server, $benutzer, $passwort);
		$db_found = mysql_select_db($datenbank, $db_handle);
		
		if ($db_found) {
		
		$SQL = "SELECT * FROM table_registration WHERE `reg_number` LIKE '$booknr'
		       ";
		$result = mysql_query($SQL);
		
		/* $reg_number = $db_field['reg_number']; */
		
		while ( $db_field = mysql_fetch_assoc($result) ) {

		    echo '<div id="explainasterix2">(All fields must be completed!)</div>';
		    include('testing.php');
		    
		    
		    
		    echo '<br><br><br><br>';		
		}
				mysql_close($db_handle);
		
		}
		else {
		
		print "Database NOT Found ";
		mysql_close($db_handle);

        }
  




	    
      ?>	               
    
  <div id="message"><?php echo $er_msg;  ?></div>


</body>
[/code]

You are missing Location:

[php]header(‘Location: thanks.php’); [/php]

Additionally, you are using obsolete mysql calls that will not work in php7. You need to use PDO with parameterized query’s. Your code is vulnerable to sql injection. You never pass user supplied data directly to the database.

You are also missing two closing div tags and you dont need to manually close the connection. It is automatically closed after the script runs.

If you had error reporting turned on you would be getting an undefined variable error from $er_msg

You are mixing using upper and lower case for variable names. Stick to all lowercase ($SQL)

Sponsor our Newsletter | Privacy Policy | Terms of Service