I'm receiving an 'undefined index' error when calling a new window and I can't quite figure out why. Seems to me like the variable is not being passed, or holds no value, and again I can't figure out why. I use an identical code for 'state' with no issues.
Here is the code:

// Here is the initial page where i pass the variable

$sql="SELECT DISTINCT city FROM users WHERE state='$state' GROUP BY city";

	<a href="javascript: void(0)" 
  'width=125, \
   height=500, \
   directories=no, \
   location=no, \
   menubar=no, \
   resizable=no, \
   scrollbars=1, \
   status=no, \
  return false;">
  <?=$city?></a><br />
    <? } ?>

// Here is the page  where I receive the variable

$sql="SELECT id FROM users WHERE city='$city'";

echo "".$num." users";


Perhaps I've been staring at this thing for too long. I must be overlooking something simple. Any ideas?

Member Avatar for diafol

You need $_GET instead of $_GET I think.

And there you have it ... LOL. An extra set of eyes always helps. I knew I was overlooking something simple. Thanks Ardav, Problem solved.

I,m getting : Undefined index: submit in C:\wamp\www\tag\chur\Maelezoyakiroho.php on line 2 help me

if($submit =!$_POST)

<form action="Registration.php" method="post" return onsubmit="formSubmit()" >
<table align="center">

<tr><td>Idara aliyopo:</td><td><input type="text" name="departmentid" /></td></tr>
<tr><td>Namba ya usajili:</td><td><input type="text" name="nambayamuumini" /></td></tr>
<tr><td>Jina kamili:</td><td><input type="text" name="jinakamili" /></td></tr>

<tr><td>Tarehe ya kuzaliwa</td><td><input type="text" name="tareheyakuzaliwa" /></td>

<tr><td>Mahali alipozaliwa :</td><td><input type="text" name="mahali" /></td></tr>
<tr><td>Wilaya :</td><td><input type="text" name="Wilaya" /></td></tr>
<tr><td>Mkoa :</td><td><input type="text" name="mkoa" /></td></tr>
<tr><td>Uraiya wake :</td><td><input type="text" name="uraiya" /></td></tr>
<tr><td>Jinsia :</td><td><select name="jinsia" ><option></option><option>Mume</option><option>Mke</option></select> </td></tr>
<tr><td>Kabila :</td><td><input type="text" name="kabila" /></td></tr>
<tr><td>Hali ya ndoa :</td><td><select name="ndoa"><option></option><option>Nimeolewa</option><option>Nimeoa</option></option><option>Sijaoa</option></option><option>Sijaolewa</option></option><option>Tumetengana</option></option><option>Mjane</option></select></td></tr>
<tr><td>Kama una ndoa Jina la mwenzi wako :</td><td><input type="text" name="mwenzi" /></td></tr>
<tr><td>Mwenzi wako ameokoka :</td><td><select name="ameokoka" ><option></option><option>Ndiyo</option><option>Hapana</option></select></td></tr>
<tr><td>Mahali anapo abudu :</td><td><input type="text" name="anapoabudu" /></td></tr>
<tr><td>Mwaka wa ndoa :</td><td><input type="text" name="mwakawandoa" /></td></tr>
<tr><td>Idadi ya watoto :</td><td><input type="text" name="idadiyawatoto" /></td></tr>
<tr><td>Wanaoabudu hapa kanisani :</td><td><input type="text" name="wanaoabudu" /></td>
<tr><td>Jina la mtaa unapoishi :</td><td><input type="text" name="mtaa" /></td></tr>
<tr><td>kata :</td><td><input type="text" name="kata" /></td></tr>
<tr><td>Unapoishi ni : </td><td><select name="unapoishini"><option></option><option>Kwako</option><option>Umepanga</option></option><option>Nakaa kwa ndugu</option></option><option>Nyingine</option></select></td></tr>
<tr><td>Namba ya simu yako</td><td><input type="text" name="simuyake" /></td></tr>
<tr><td>Barua pepe(Email)</td><td><input type="text" name="email" /></td></tr>
<tr><td>Kazi yako</td><td><input type="text" name="kazi" /></td></tr>
<tr><td>Ndugu wa karibu</td><td><input type="text" name="ndugu" /></td></tr>
<tr><td>Mahali Anapoishi</td><td><input type="text" name="nduguanapoishi" /></td></tr>
<tr><td>Namba yake ya simu ndugu</td><td><input type="text" name="simuyandugu" /></td></tr>
<tr><td>Uhusiano wake na wewe</td><td><input type="text" name="uhusiano" /></td></tr>
<tr><td colspan="2"><b>Maoni ya kanisa</b></td></tr>
<tr><td colspan="2"><textarea cols="40" rows="5" name="maoni"></textarea></td></tr>
<p align="center"><input type="submit" value="submit" name="submit" ><input type="reset" value="FUTA" name="reset" onclick="formSubmit()" ></p>

<p align="center"><font color="#0000FF" size="4" face="Geneva, Arial, Helvetica, sans-serif" ><a href="reportusajil.php"><font color="#FFFFFF">Report ya usajili</font></a>|</font></p>
die ('Ingiza namba ya idara ya usajili') : mysql_escape_string($_POST);
die ('UMEKOSEA: Ingiza a namba ya muumini') : mysql_escape_string($_POST));
die ('UMEKOSEA: Ingiza jina kamili') : mysql_escape_string($_POST));

die ('UMEKOSEA: Ingiza tarehe ya kuzaliwa') : mysql_escape_string($_POST));

die ('UMEKOSEA: Ingiza mahali alipozaliwa') : mysql_escape_string($_POST));

die ('UMEKOSEA: Ingiza wilaya aliyozaliwa') : mysql_escape_string($_POST));
die ('UMEKOSEA: Ingiza mkoa alikozaliwa') : mysql_escape_string($_POST));

die ('UMEKOSEA: Ingiza uraiya yake') : mysql_escape_string($_POST));
die ('UMEKOSEA: Ingiza jinsia') : mysql_escape_string($_POST));
die ('UMEKOSEA: Ingiza kabila lake') : mysql_escape_string($_POST));

//die ('ERROR: Jaza sehemu ya ndoa') : mysql_escape_string($_POST));

// die ('ERROR: Jaza sehemu ya mwenzi wake') : mysql_escape_string($_POST));
// die ('ERROR: Jaza sehemu ya mwenzi ameokoka') : mysql_escape_string($_POST));
//die ('ERROR: Jaza sehemu ya anapoabudu') : mysql_escape_string($_POST));
// die ('ERROR: Jaza sehemu ya mwaka wa ndoa') : mysql_escape_string($_POST));
// die ('ERROR: Jaza sehemu ya idadi ya watoto') : mysql_escape_string($_POST));

//die ('ERROR: Jaza sehemu ya wanapoabudu') : mysql_escape_string($_POST));
die ('ERROR: Jaza sehemu ya mtaa unapoishi') : mysql_escape_string($_POST));

die ('UMEKOSEA: Jaza sehemu ya kata') : mysql_escape_string($_POST));
die ('UMEKOSEA: Jaza sehemu ya unapoishi') : mysql_escape_string($_POST));
die ('UMEKOSEA: Jaza sehemu ya namba simu ') : mysql_escape_string($_POST));

$email=(!isset($_POST)|| !ereg('^([a-zA-Z0-9_-]+)([\.a-zA-Z0-9_-]+)@([a-zA-Z0-9_-]+)([\.a-zA-Z0-9_-]+)+$', $_POST))? die ('UMEKOSEA: Email imekusewa kuandikwa'):mysql_escape_string(trim($_POST));

die ('UMEKOSEA: Jaza sehemu ya kazi') : mysql_escape_string($_POST));
die ('UMEKOSEA: Jaza sehemu ya ndugu wa karibu') : mysql_escape_string($_POST));

die ('UMEKOSEA: Jaza sehemu ya ndugu anapoishi') : mysql_escape_string($_POST));
die ('UMEKOSEA: Jaza sehemu ya simu ya ndugu') : mysql_escape_string($_POST));
die ('UMEKOSEA: Jaza sehemu ya uhusiano') : mysql_escape_string($_POST));
die ('UMEKOSEA: Jaza sehemu ya maoni ya kanisa') : mysql_escape_string($_POST));

$connection=mysql_connect('localhost', 'root','')
or die ('Unable to connect!');
mysql_select_db('tagt') or die ('Unable to select database');

$query="INSERT INTO `tagt`.`registration` (`departmentid`, `nambayamuumini`, `jinakamili`, `tareheyakuzaliwa`, `mahali`, `Wilaya`, `mkoa`, `uraiya`, `jinsia`, `kabila`, `ndoa`, `mwenzi`, `ameokoka`, `anapoabudu`, `mwakawandoa`, `idadiyawatoto`, `wanaoabudu`, `mtaa`, `kata`, `unapoishini`, `simuyake`, `email`, `kazi`, `ndugu`, `nduguanapoishi`, `simuyandugu`, `uhusiano`, `maoni`) values('$departmentid', '$nambayamuumini', '$jinakamili', '$tareheyakuzaliwa', '$mahali', '$Wilaya', '$mkoa', '$uraiya', '$jinsia', '$kabila', '$ndoa', '$mwenzi', '$ameokoka', '$anapoabudu', '$mwakawandoa', '$idadiyawatoto', '$wanaoabudu', '$mtaa', '$kata', '$unapoishini', '$simuyake', '$email', '$kazi', '$ndugu', '$nduguanapoishi', '$simuyandugu', '$uhusiano', '$maoni')";

$result=mysql_query($query) or die ("Error in query: $query. " . mysql_error());
//echo 'New record inserted with ID ' . mysql_insertde_id(). '<br\>';
echo mysql_affected_rows() . 'Umesajili muumini';


help me to remove and error above .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.