The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Warning! Undefined variable
tudsy
post Apr 4 2023, 12:40 AM
Post #1


Advanced Member
****

Group: Members
Posts: 246
Joined: 30-September 14
Member No.: 21,611



Hi

I am getting a warning for an undefined variable. The program works but I get a warning that there is an undefined variable in the program.

mywriting.php ->form.php

error_log file is attached.


Thanks.


Attached File(s)
Attached File  mywriting.txt ( 15.25k ) Number of downloads: 147
Attached File  form.txt ( 6.15k ) Number of downloads: 153
Attached File  error_log.txt ( 1.08k ) Number of downloads: 157
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post Apr 5 2023, 06:06 PM
Post #2


Programming Fanatic
********

Group: Members
Posts: 1,981
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



I looked over mywriting.php and nothing jumps out at me. I did notice that your 1st form is missing a closing ul tag. I don't know if this would cause the problem. If you ever decide to allow multiple book purchases you have major rewriting to do.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Apr 6 2023, 07:51 PM
Post #3


.
********

Group: WDG Moderators
Posts: 9,630
Joined: 10-August 06
Member No.: 7



CODE
if(isset($_POST['Book'],$_POST['Price'])){
    
    
$book = $_POST['Book'];
$Price = $_POST['Price'];

}

The above means the variables are not set if the form page is loaded without a previous form submission:

CODE
<title>Order Form for <?php echo $_POST['Book']; ?></title>
...
<h1> Order form for <?php echo $_POST['Book']; ?> at (AUD)  $  <?php echo $_POST['Price']; ?> </h1>


(As a sidenote, there's no sanitation of the above POST data. Possibly a malicious user could inject unwanted code in your PHP script that way, like manipulating the price.)
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 28th March 2024 - 08:05 AM