|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
AT&T devCentral & BlackBerry(r) Webcast Series: BlackBerry and GPS -Build Location Awareness into your BlackBerry Applications, July 10th-1:00PM EST. Register Today!
|
|
#1
|
|||
|
|||
|
I am new to php and trying a simple load script. I have scaled it down to try to find the problem. When it gets to the elseif statement, it just displays the form. I know that the op and the names are set (I can echo them back just prior to the elseif). If I skip the elseif, the data loads just fine. Any help on the basic, yet frustrating issue would be greatly appreciated.
================================================== =============== <?php if ($POST[op] != "add") { $display_block = "<form method=\"post\" action=\"$_SERVER[PHP_SELF]\"> <p>Primary Parent bringing child(ren) to park: <br> First name: <input type=\"text\" name=\"mem_first\" size=25><br> Last name: <input type=\"text\" name=\"mem_last\" size=25><br></p> <input type=\"hidden\" name=\"op\" value=\"add\"> <p><input type=\"submit\" name=\"submit\" value=\"Add Entry\"></p> </form>"; //These lines echo back the op and names with no problem, just above the form re-display, so I know they are there echo "$_POST[op]; echo "$_POST[mem_first]"; echo "$_POST[mem_last]"; } elseif ($_POST[op] == "add") { //time to add to tables, so check for required fields if (($_POST[mem_first] == "") || ($_POST[mem_last] == "")) { header("Location: addtest.php"); exit; } // I never get this far, unless I take out the elseif. echo "made it past the else statement"; $conn = mysql_connect("localhost", "root") or die(mysql_error()); mysql_select_db('cip',$conn) or die(mysql_error()); $add_member="insert into member values ('','$_POST[mem_first]', '$_POST[mem_last]', 'new', 'circle', #'$_POST[status]', '$_POST[park]', '$_POST[spouse_first]', '$_POST[spouse_last]', 'n', #'$_POST[daycare_provider]', now(), now())"; mysql_query($add_member) or die(mysql_error()); . . . . ================================================== ========== |
|
#2
|
|||
|
|||
|
Problem solved - I'm pretty embarrassed - total newbie mistake. Forgot underscore in second line. I looked at it all night last night - guess I needed some sleep.
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > Elseif statement being ignored - ? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|