Undefined Index - isset() doesn't fix it

I get this undefined index notice when I access the page where to choose the category in which to post a classified ad in my script.

Error is in the first line of the snippet. I have tried to surround the $_GET['postevent'] with an isset(), it makes the notice disappear, but then script doesn't work properly. There must be another solution.
elseif (($_GET['subcatid'] || $_GET['postevent']) && $xcityid > 0)
{
	// Show the form //
 
	if($_GET['subcatid'] == -1)
	{
		$_GET['postevent'] = $_REQUEST['postevent'] = 1;
	}

Open in new window

jimgordonAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
nplibConnect With a Mentor Commented:
I'm sorry to say, but there is just too many mistakes,

plus in your form action you have this.
action="<?php if($in_admin) echo "postad.php?cityid=$_GET[cityid]&subcatid=$_GET[subcatid]"; else echo "index.php?$qs"; ?>"
which places subcatid in the querystring, for $_GET variables,

you have an input called subcatid which is for you $_POST variables

without having the application in front of me, there is no way of knowing if what I'm doing is going to fix your problems.

also you have many array objects done wrong, for example in your form tag
<form action="<?php if($in_admin) echo "postad.php?cityid=$_GET[cityid]&subcatid=$_GET[subcatid]"; else echo "index.php?$qs"; ?>" method="post" name="frmPost" enctype="multipart/form-data">
anything that has [] brackets like $_GET[cityid] needs to be $_GET['cityid'], you gave many array objects done that way. The assocation part of the array needs to be in quotes.

You can close this question or ask it again, or what ever, but the amount of work needed to fix this, will take me several hours to do. Plus I would need access to your entire application. In other words I would needa all the files associated with this. Then I would need a break down of how this is supposed to work and what you want done with it.

This amount work isn't free. I'll be glad to do it, but at a cost.

This goes back to your previous post, the quote I said,

I've been reading a lot of your past posts, you've been given much advice from may different programmer, and there is nothing wrong with that, however you haven't fully learned what the advice is teaching you, and now you have a massive script, with a huge problem, where there is no simple fix.

I would strongly suggest, starting over, and try to fully understand what it is your are doing.

goto sites like
www.php.net
www.w3schools.com
look for information, not tutorials

following the guidelines to Object Oriented Programming
0
 
nplibCommented:
this is why initially I said, put every thing in variables, then use.

but instead of posting the code you went ahead and accepted that other guys answer.

Which did exactly what you didn't want.

Solve one, to break another.

so post, code, and we can put an end to this.
0
 
jimgordonAuthor Commented:
I attach the file. For this issue, we are on line 509.
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
hieloCommented:
Did you try this:
elseif (( isset($_GET['subcatid']) || isset($_GET['postevent'])) && ( isset($xcityid) && $xcityid > 0))
0
 
jimgordonAuthor Commented:
This is the entire file. Go to line 509.
post.txt
0
 
nplibCommented:
it didn't get attached.

you need to make it a text file first, or just copy and paste the code into the code snippet box.
0
 
jimgordonAuthor Commented:
Dear hielo, I tried it now. It doesn't work. It makes the notice disappear, but it makes script work not properly: That is, if I select a city, then I cannot select the category and I directly enter the form to insert an ad in a category i do not have chosen.
0
 
nplibCommented:
there are tons of errors in this script.

It's going to take some time to fix.
0
 
jimgordonAuthor Commented:
You think there will be a solution or should I close this question?
0
 
nplibCommented:
why do you mix
$_POST
$_GET
$_RESULT

There are times that it makes sense to mix, but not often, but the use of $_RESULT covers both post and get, so I don't understand why it's thrown in the mix.
0
 
nplibCommented:
if your form using post or get?
0
 
jimgordonAuthor Commented:
it uses post, I guess: so you can see in the attached file at line 614:

<form action="<?php if($in_admin) echo "postad.php?cityid=$_GET[cityid]&subcatid=$_GET[subcatid]"; else echo "index.php?$qs"; ?>" method="post" name="frmPost" enctype="multipart/form-data">

I think is this the form we are dealing with...
Sorry but I'm not the developer of the script. I am trying to fix it.
0
 
jimgordonAuthor Commented:
nplip: should I change every POST and GET in the file with RESULT?
0
 
nplibCommented:
it's not as simple as just change the posts and gets, I just need to know so I can fix it.
and judging by your form, it uses both. but you don't need $_RESULT in this case, because you have a specific need for $_GET and one for $_POST

give me some time.

I'll get back to you.
0
 
jimgordonAuthor Commented:
Tell me if you need more code, other files. Thanks a lot, you are very kind.
0
 
jimgordonAuthor Commented:
I thank you and I accept as a solution your suggestions. I would like to let you see my entire script and ask you for a quote, since I really desire to fix it. Tell me if you can. Otherwise... thanks a lot again.

Cosimo.
0
 
nplibCommented:
email me
kefka1911@gmail.com
0
All Courses

From novice to tech pro — start learning today.