Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  nodelist  faq  

Newton's Little-Known Seventh Law: A bird in the hand is safer than one overhead.


rocksolid / Helpdesk / Re: Notice: Undefined variable:

SubjectAuthor
* Notice: Undefined variable:Anonymous
+- Could it be a typo ?trw
+* Re: Notice: Undefined variable:Retro Guy
|`- Re: Notice: Undefined variable:Retro Guy
`* Re: Notice: Undefined variable:Anonymous
 `- Re: Notice: Undefined variable:Anonymous

1
Subject: Notice: Undefined variable:
From: Anonymous
Newsgroups: rocksolid.shared.helpdesk
Organization: novaBBS
Date: Sun, 20 Dec 2020 00:43 UTC
Path: i2pn2.org!.POSTED!not-for-mail
From: Anonym...@novabbs.i2p (Anonymous)
Newsgroups: rocksolid.shared.helpdesk
Subject: Notice: Undefined variable:
Date: Sun, 20 Dec 2020 00:43:32 +0000
Organization: novaBBS
Message-ID: <00178a157a08fbb015413efe9715b88b$1@news.novabbs.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: i2pn2.org; posting-account="retrobbs1";
logging-data="18097"; mail-complaints-to="usenet@i2pn2.org"
User-Agent: Rocksolid Light (news.novabbs.com/getrslight)
X-Rslight-Site: $2y$10$4.8yl8YZBfEStW8uDNxJQuN3Yd3sdIuJoJ9dtJMiJ5aPoevg7AcES
View all headers
Hello. I'm in a need of a bit of help. I'm trying to make a website in php. However, in order for users to access a page in this website, they'll need to have an account. This account requires a captcha. However, whenever I try to get an account, my error logs say that a variable is undefined. Here's part of my code:

index.php:

<!doctype html>
<html>
<head>
<style>
*{margin:{number}px; padding:{number}px;}
#account{border-radius: {number}px {number}px {number}px {number}px; border: {number}px solid {color}; width:
{number}px; margin-top: {number}px; margin-left: {number}px; }
#login{border-radius: {number}px {number}px {number}px {number}px; border: {number}px solid {color}; width: {number}px; margin-top: {number}px; margin-left: {number}px; margin-right: {number}px; }
</style>
</head>

<body style="background-color:{color}">
#####<?PHp
               require_once("connect.php") ;
      if(isset($_POST['register'])){
    $user_name = $_POST['user_name'] ;
$password = $_POST['password'] ;

    if($user_name != "" and $password != "" and $_POST['code'] === $_SESSION['captcha_code'])

    $q= "INSERT INTO `user` (`id`, `user_name`, `password`)
       VALUES(' ' , ' ".$user_name." ' , ' ".$password." ')
    " ; if(mysqli_query($con, $q)){
   echo '{text1}' ;
               }else{                       echo "(text2)" ;
               }

               }

?>#####
<h1><strong>{Some Text}<strong></h1>
<div id="registration">
<h2>{Some Text}</h2>
<form method="post">
Intended username:<br>
<input type="text" name="user_name" /><br>
Intended password:<br>
<input type="text" name="password" /><br>
#####<img src="cap.php"><br/><label for="code">captcha:</label><input type="text" name="code" />#####
<input type="submit" name="register" value="Submission" />

</form>
</div>
</body>
</html>

cap.php:

<?php
session_start( ) ;

#####$captcha = ' ' ;

for($x = 0 ; $x< 7 ; $x++){

     $captcha .=chr(rand(97, 122)) ;
}
$_SESSION['captcha_code'] = $captcha ;#####

$font = '/fonts/ttf/28dayslater.ttf' ;

$image = imagecreatetruecolor(170, 60) ;

${variable1} = imagecolorallocate($image, {number}, {number}, {number}) ;
${variable2} = imagecolorallocate($image, {number}, {number}, {number}) ;
${variable3} = imagecolorallocate($image, {number}, {number}, {number}) ;

imagefilledrectangle($image, 0, 0, 200, 100, ${variable3}) ;
#####imagettftext($image, 30, 5, 10, 40, ${variable}, $font, $_SESSION['captcha_code']) ;#####

header("Content-type: image/png") ;
imagepng($image) ;

?>

Error Log Output:

#####Notice: Undefined variable: _SESSION in {directory}/index.php on line {number}#####

For what connect.php is and what the INSERT INTO values are as mentioned above in index.php, they're databases that are used in order for users to register, and I also believe that they're unimportant in terms of my issue. The different {number}, {color}, {text}, {directory}, and {variable} brackets are supposed to represent different elements in my code that I believe aren't necessary to type out and are also elements that I feel somewhat insecure sharing. Of course, if there's any information that I can provide you or anything that you're confused about, then please feel free to ask. Since the code may be a bit long to some, I put hashtags around sections of code that I think are especially important to read. Anyway, I believe that with the code that I wrote out, the SESSION variable shouldn't be undefined, as it was defined in cap.php (captcha). However, here I am, not knowing why I keep on getting this error and {text2}. If you have any idea why I may be getting this error, if you see a mistake in the code, and/or if you know any links and websites that might help, please reply. I would love some advice, as I don't know what's wrong at all. Thanks.

--
Posted on novaBBS
news.novabbs.com


Subject: Could it be a typo ?
From: trw
Newsgroups: rocksolid.shared.helpdesk
Organization: def5
Date: Sun, 20 Dec 2020 01:12 UTC
Path: i2pn2.org!rocksolid2!def5!POSTED.localhost!not-for-mail
From: trw...@anon.com (trw)
Newsgroups: rocksolid.shared.helpdesk
Message-ID: <b57b69c78175acb392f5039503868450@def4>
Subject: Could it be a typo ?
Date: Sun, 20 Dec 2020 01:12:10+0000
Organization: def5
In-Reply-To: <00178a157a08fbb015413efe9715b88b$1@news.novabbs.com>
References: <00178a157a08fbb015413efe9715b88b$1@news.novabbs.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
View all headers

session_start( ) ;
When I do copy and paste, there is a whitespace between the brackets, where it should say:
session_start();

cheers

trw

--
Posted on def4


Subject: Re: Notice: Undefined variable:
From: Retro Guy
Newsgroups: rocksolid.shared.helpdesk
Organization: RetroBBS
Date: Sun, 20 Dec 2020 10:21 UTC
Path: i2pn2.org!rocksolid2!.POSTED.localhost!not-for-mail
From: retro_...@retrobbs.rocksolidbbs.com (Retro Guy)
Newsgroups: rocksolid.shared.helpdesk
Subject: Re: Notice: Undefined variable:
Date: Sun, 20 Dec 2020 03:21:37 -0700
Organization: RetroBBS
Message-ID: <20201220032137.1412dd1a@desktop14.dt>
References: <00178a157a08fbb015413efe9715b88b$1@news.novabbs.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: novabbs.org; posting-account="retrobbs1"; posting-host="localhost:127.0.0.1";
logging-data="13421"; mail-complaints-to="usenet@novabbs.org"
X-Newsreader: Claws Mail 3.11.1 (GTK+ 2.24.25; x86_64-pc-linux-gnu)
View all headers
On Sun, 20 Dec 2020 00:43:32 +0000
Anonymous@novabbs.i2p (Anonymous) wrote:

Hello. I'm in a need of a bit of help. I'm trying to make a website
in php. However, in order for users to access a page in this website,
they'll need to have an account. This account requires a captcha.
However, whenever I try to get an account, my error logs say that a
variable is undefined. Here's part of my code:

Usually the log would tell you which variable is undefined. Then you
know which variable you need to trace back to see when it should get
defined. Does the log provide this info?



Subject: Re: Notice: Undefined variable:
From: Retro Guy
Newsgroups: rocksolid.shared.helpdesk
Organization: Rocksolid Light
Date: Sun, 20 Dec 2020 10:38 UTC
Path: i2pn2.org!i2pn.org!rocksolid2!.POSTED.localhost!not-for-mail
From: retro....@rocksolidbbs.com (Retro Guy)
Newsgroups: rocksolid.shared.helpdesk
Subject: Re: Notice: Undefined variable:
Date: Sun, 20 Dec 2020 10:38:02 +0000
Organization: Rocksolid Light
Message-ID: <65f85e14e588904d442f0de127cbe004$1@news.novabbs.org>
References: <00178a157a08fbb015413efe9715b88b$1@news.novabbs.com> <20201220032137.1412dd1a@desktop14.dt>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: novabbs.org; posting-account="retrobbs1"; posting-host="localhost:127.0.0.1";
logging-data="21856"; mail-complaints-to="usenet@novabbs.org"
User-Agent: Rocksolid Light (news.novabbs.com/getrslight)
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on novabbs.org
X-Rslight-Site: $2y$10$iK2NYzEzWdoiExXvJlJNluEQax6pVoNokQM4Ad2rIdcfgW1Uj1pgO
View all headers
Retro Guy wrote:

Usually the log would tell you which variable is undefined. Then you
know which variable you need to trace back to see when it should get
defined. Does the log provide this info?

I somehow missed the bottom of your post where you say it's _SESSION that's undefined.

Do you have session_start() also in index.php? Without it you won't have $_SESSION variables available.

--
Posted on Rocksolid Light
news.novabbs.org


Subject: Re: Notice: Undefined variable:
From: Anonymous
Newsgroups: rocksolid.shared.helpdesk
Organization: rocksolid2 (novabbs.org)
Date: Sun, 20 Dec 2020 13:07 UTC
Path: i2pn2.org!rocksolid2!.POSTED.127.117.190.215!not-for-mail
From: pos...@anon.com (Anonymous)
Newsgroups: rocksolid.shared.helpdesk
Subject: Re: Notice: Undefined variable:
Date: Sun, 20 Dec 2020 05:07:12 -0800
Organization: rocksolid2 (novabbs.org)
Message-ID: <he.660.48msjb@anon.com>
References: <00178a157a08fbb015413efe9715b88b$1@news.novabbs.com>
Content-Type: text/plain; charset=UTF-8
Injection-Info: novabbs.org; posting-account="def.i2p"; posting-host="127.117.190.215";
logging-data="27027"; mail-complaints-to="usenet@novabbs.org"
View all headers
50d90268088e7734ea
Do you have session_start() also in index.php? Without it you won't have $_SESSION variables available.

Are you sure ? I thought $_SESSION is a superglobal.

--
Posted on def2


Subject: Re: Notice: Undefined variable:
From: Anonymous
Newsgroups: rocksolid.shared.helpdesk
Organization: novaBBS
Date: Sun, 20 Dec 2020 23:19 UTC
Path: i2pn2.org!.POSTED!not-for-mail
From: Anonym...@novabbs.i2p (Anonymous)
Newsgroups: rocksolid.shared.helpdesk
Subject: Re: Notice: Undefined variable:
Date: Sun, 20 Dec 2020 23:19:07 +0000
Organization: novaBBS
Message-ID: <2e7dc8318d17415313085feea1e3ae0b$1@www.novabbs.com>
References: <00178a157a08fbb015413efe9715b88b$1@news.novabbs.com> <he.660.48msjb@anon.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: i2pn2.org; posting-account="retrobbs1";
logging-data="17066"; mail-complaints-to="usenet@i2pn2.org"
User-Agent: Rocksolid Light (news.novabbs.com/getrslight)
X-Rslight-Site: $2y$10$bk6LULWpmz.WfGd/RhsACeDHqULmOxmFF.slYBOH2mL.XKJwpx79C
View all headers
Anonymous wrote:

50d90268088e7734ea
Do you have session_start() also in index.php? Without it you won't have $_SESSION variables available.

Are you sure ? I thought $_SESSION is a superglobal.

It is as long as you session_start()

https://errorsea.com/what-is-the-php-session-and-how-to-use-_session/

--
Posted on novaBBS
www.novabbs.com


1
rocksolid light 0.6.9
clearneti2ptor