• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1295
  • Last Modified:

Error : Deprecated: Function session_register() is deprecated

I know why I'm getting it  - I know what the error is. error on line 18


What do I need to change

Second one I had today http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_25970442.html


<?php
session_start();
$PHP_SELF = $_SERVER['PHP_SELF'];
$errore = 0;
if(isset($_POST['submit']) && isset($_SESSION['captcha'])) {
	if(isset($_POST['code'])){
		$_code = $_POST['code'];
		if($_SESSION['captcha'] == $_code){
			header("Location: go.html");
			exit;
		} else {
			$errore = 1;
		}
	} else {
		$errore = 1;
	}
}
if(!isset($_SESSION['captcha'])){session_register('captcha');}	
$PHP_SELF = $_SERVER['PHP_SELF'];
$stringa = '';
$cifre = 5;
for($i=1;$i<=$cifre;$i++){
	$letteraOnumero = rand(1,2);
	if($letteraOnumero == 1){
		// lettera
		$lettere = 'ABEFHKMNRVWX';
		$x = rand(1,11);
		$lettera = substr($lettere,$x,1);
		$stringa .= $lettera;
	} else {
		$numero = rand(3,7);
		$stringa .= $numero;
	}
}
$_SESSION['captcha'] = $stringa;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Verify You Are Human!</title>
<link href="../PNL-CSS-2-Column.css" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" href="http://petenetlive.com/images/favicon.ico" type="image/x-icon">
<style type="text/css">
#captcha{margin:0 auto;text-align:center}
.errore{color:#f00}
body,td,th {
	color: f0f0f0;
}
body {
	background-color: #993300;
}
.style5 {font-family: Verdana, Arial, Helvetica, sans-serif}
</style>
</head>

<body>
<div id="captcha">
	<p><img src="captcha.php" /></p>
  <p class="style5"><span class="style5"><strong>To proceed to the web form please<br />
    insert the code you see above into the Code field below<br />
    and then click the enter button.
  </strong> <br />
    [ any letters you see should be inserted as CAPITALS and if you<br /> 
    have difficulty in reading the image above then refresh your browser <br />
    a few times until you see an image that is clear enough to copy
  ]  </span></p>
  <p class="style5">If you get the code wrong, you will be allerted and can try again </p>
<form id="captchaform" action="<?php echo $PHP_SELF ?>" method="post">
		<p><label for="code"><span class="style4">Code</span>: </label>
	<input type="text" name="code" id="code" /></p>
		<p><input type="submit" id="submit" name="submit" value="Enter" /></p>
  </form>
	<?php if($errore == 1){ ?>
  <p class="errore style5"><span class="style4">The code you inserted was not correct .</span><br />
	<a href="<?php echo $PHP_SELF ?>" class="style5">Click here to generate a new Captcha code and try again</a></p>
  <?php } ?>
</div>
</body></html>

Open in new window

0
Pete Long
Asked:
Pete Long
1 Solution
 
Om PrakashCommented:
Replace
if(!isset($_SESSION['captcha'])){session_register('captcha');}      
with
if(!isset($_SESSION['captcha'])){$_SESSION['captcha'];}      
0
 
Pete LongTechnical ConsultantAuthor Commented:
Spot on - Points well deserved
0
 
Avinash ZalaWeb ExpertCommented:
use this:

replace
session_register('captcha');

with

$_SESSION['captcha'];


Hope this helps,
Addy
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now