Solved

php -> 5.5.9

Posted on 2014-11-17
8
475 Views
Last Modified: 2014-11-17
My host server was updated to php 5.5.9 (from 5.4.1) and my php form are not working anymore. Do anyone see some errors?


Start ----

<?php
include('userpass.php');
include('config.php');

$user_id = $_SESSION['username'];
$book_id = $_GET['book_id'];
$varsling = $_GET['varsling'];


//echo "$user_id, $book_id, $FormDict";

$cnx =mysql_connect ($db_host ,$db_user ,$db_pass ); 
mysql_select_db ($database ,$cnx );
 

	$err=0;
	$FormDict = $HTTP_GET_VARS;
	
if ($HTTP_POST_VARS['_wss']) {
		$FormDict = $HTTP_POST_VARS;

	}
	$errUrl = 'main.php';
	$thanksUrl = 'main.php';
	if ($FormDict['_wss'] && strlen($FormDict['errMsg']) < 1) {
		mysql_pconnect($db_host, $db_user,$db_pass);
		mysql_select_db($db_user);
		$stmt = "insert into $booking_log_table (user_id, book_id, info, aktiv, varsel) values (";
		$fields = array("user_id", "book_id", "info","aktiv","varsel");
		$checks = array("-:-:-:", "-:-:-:", "-:-:-:", "-:-:-:", "-:-:-:");
		for($i=0; $i < 5; $i++) {
			$val = $FormDict[$fields[$i]];
			$c = preg_split("/:/", $checks[$i]);
			if ((strcmp($c[0], 'r') == 0) && !$val) $err++;
			if (strcmp($c[1], 'l') == 0) $val = strtolower($val);
			if (strcmp($c[1], 'u') == 0) $val = strtoupper($val);
			if ($c[2] && strlen($val) < $c[2]) $err++;
			if ($c[3] && !$c[3]($val)) $err++;
			if ($i > 0) $stmt .= ',';
			$stmt .= "'" . AddSlashes($val) . "'";
		}
		$stmt .= ')';
		$rs = mysql_query($stmt);
		if (0 == $rs) {
			$err++;
			$errUrl = $errUrl . "?errMsg=" . urlencode(mysql_error());
		}
		if ($err)

 
			$thanksUrl = $errUrl;
		header("Location: $thanksUrl?time_open=1");
		exit;
	}
	/* 	This code was generated via MacSQL (available at
		<http://www.rtlabs.com/macsql/>) and is copyright 2003 Runtime Labs, LLC.
		Registered users of MacSQL are granted unlimited right to use
		this code on websites they build. This notice must be included
		with this code.
		
		This code is provided AS IS with no warranty of any kind. 
	*/
	function isInteger($val) {
		return preg_match("/^\d+$/", $val);
	}
	function isAlphaNum($val) {
		return preg_match("/^\w+$/", $val);
	}
	function hasNonAlphaNum($val) {
		return preg_match("/\W/", $val);
	}
	function isCCExpDate($val) {
		$d = preg_split("/\//", $val);
		if (strlen($d[1]) < 7) $d[1] += 2000;
		return (($d[0] > 0) && ($d[0] <= 12) && ($d[1] > 2002) && ($d[1] < 2050));
	}
	function isDate($val) {
		return preg_match("#\d\d?[-/]\d\d?[-/]\d{2,6}#", $val);
	}
?>

Open in new window

<?php //include("config.php") ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $tekstKoding ?>">
		<meta name="generator" content="Lavine WebSystem PHP/MySQL">
		<title>Meld meg p&aring; time</title>

	</head>
                                                 <?php



$sql5 =mysql_query("SELECT navn, book_id FROM $booking_table where book_id = '$book_id'" ) or die ( mysql_error ()); 
while( $row =mysql_fetch_array ($sql5 )) { 

$navnet = $row ['navn' ];

}

?>
<?php echo $navn ?>
	<?PHP if (strlen($Form['errMsg']) > 0) echo($Form['errMsg']);?>
<body background="grafikk/bk.jpg" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<div align="center">
			<table width="100%" border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td><?php include("heading.php") ?></td>
				</tr>
				<tr>
					<td>
						<form method="get" name="FormName">
							<div align="left">
								<div align="center">
								  <table border="0" cellpadding="2" cellspacing="1" bgcolor="#333333">
								    <tr>
								      <td>
								        <table width="500" border="0" cellspacing="2" cellpadding="2" bgcolor="#f5f5f5">
								          <tr>
								            <td valign="top">
								              <table width="100%" border="0" cellspacing="4" cellpadding="4">
                                                <tr>
                                                  <td><font size="3" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular">Meld meg p&aring;: 
                                                  
 </font>
                                                    <hr align="left" noshade size="1" width="100%">                                                  </td>
                                                </tr>
                                              </table>
								              <table width="500" border="0" cellspacing="4" cellpadding="4">
								                <tr>
								                  <td align="right" valign="top"><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular"><b></b></font></td>
											      <td align="left" valign="top"><?php echo $event_id ?></td>
												  </tr>
								                <tr>
								                  <td align="right" valign="top"><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular"><b>Medlemsnr.:</b></font></td>
								                  <td align="left" valign="top"><input name="user_id" type="hidden" value="<?php echo $user_id ?>" size="30" maxlength="30" border="0"><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular"><?php echo $user_id ?></font></td>
							                    </tr>
								                <tr>
								                  <td align="right" valign="top"><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular"><b>Time/Øvelse:</b></font></td>
											      <td align="left" valign="top"><input type="hidden" value="<?php echo $book_id ?>" name="book_id" size="30" maxlength="30" border="0"><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular"><?php echo $navnet ?></font></td>
											    </tr>
								                <tr>
								                  <td align="right" valign="top"><font size="2" face="Arial"><b>Beskjed:</b></font></td>
								                  <td align="left" valign="top"><textarea name="info" cols="30" rows="5" wrap="virtual"></textarea></td>
							                    </tr>
								                <tr>
								                  <td align="right" valign="top"><font size="2" face="Arial"><b>SMS-varsling:</b></font></td>
								                  <td align="left" valign="middle"><font size="2" face="Arial"><?php if($varsling=='1')$varseltext = "<label><input type=\"radio\" name=\"varsel\" value=\"1\">Ja  <input type=\"radio\" name=\"varsel\" value=\"0\" checked>Nei<br><br>(krever at ditt mobilnummer er registrert)"; else $varseltext = 'Det ser ut til at du får plass på denne treningen.<br><br> Venligst husk å meld deg av om du ikke kan komme!<br>Da vil noen på ventelista få plass!'; echo $varseltext ?>
							                      
								                  </font></td>
							                    </tr>
							                </table>										    </td>
										    </tr>
								          <tr>
								            <td>								              </td>
										    </tr>
								          <tr align="center" valign="middle">
								            <td>
								              <div align="center" valign="middle">
								                <hr align="left" noshade size="1" width="100%">
								                <input type="submit" name="submit" value="Meld meg på denne timen"></div>											  </td>
										    </tr>
								          </table>									    </td>
								      </tr>
								    </table>
								  <input type="hidden" name="_wss" value="1">
								  <input type="hidden" name="_wss" value="1">
							  </div>
							</div>
					  </form>
					</td>
				</tr>
				<tr>
					<td><div align="center"><?php include("footer.php") ?></div></td>
				</tr>
			</table>
		</div>
	</body>

</html>

Open in new window



--- END
0
Comment
Question by:Hans Inge Hagen
  • 3
  • 3
8 Comments
 
LVL 58

Expert Comment

by:Gary
Comment Utility
First thing is
HTTP_GET_VARS

...maybe others but enable error reporting so it tells you these problems
0
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
What is the symptom of failure?

I would suggest to start the debugging process by adding error_reporting(E_ALL) to the top of the scripts.  You might also want to test for the return values from the PHP functions.  For example, consider this.  Both of these functions return values to your PHP script, but the script does not test to see if the return values indicate that the functions actually worked!
$cnx =mysql_connect ($db_host ,$db_user ,$db_pass ); 
mysql_select_db ($database ,$cnx );

Open in new window

0
 

Author Comment

by:Hans Inge Hagen
Comment Utility
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/sporty/www/medlemer/event_booking.php on line 15

Notice: Undefined variable: HTTP_GET_VARS in /home/sporty/www/medlemer/event_booking.php on line 20

Notice: Undefined variable: HTTP_POST_VARS in /home/sporty/www/medlemer/event_booking.php on line 22

Notice: Undefined variable: navn in /home/sporty/www/medlemer/event_booking.php on line 107

Notice: Undefined variable: Form in /home/sporty/www/medlemer/event_booking.php on line 108
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
Thanks, that's helpful.  For the HTTP_GET_VARS you can switch over to using $_GET.  Same pattern for POST.
http://php.net/manual/en/reserved.variables.get.php

For the MySQL issues, be aware that PHP is doing away with MySQL support and you will need to switch over to another extension.  This article explains why PHP is doing that and what you must do to keep your scripts running.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/PHP_Databases/A_11177-PHP-MySQL-Deprecated-as-of-PHP-5-5-0.html
0
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 500 total points
Comment Utility
$navn and $Form appear to be undefined variables.  Perhaps they are confused with other variable names (like maybe $navnet)?  Unfortunately PHP does not tell you about reliance on an undefined variable unless you raise the error_reporting() level.  Probably the best thing to do is review the program logic and see if you really need these variables.  If so, you'll want to change the scripts to provide the right data for these variables.  If not, you'll also want to change the scripts to remove the reliance.
0
 

Author Comment

by:Hans Inge Hagen
Comment Utility
Thanks a lot, Ray! Im sure I will be able to fix this now. Thanks.
0
 

Author Closing Comment

by:Hans Inge Hagen
Comment Utility
Very good!
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now