swatisonee Posted May 13, 2010 Share Posted May 13, 2010 hi, I have the following code. as commented out, i need to select a value from an array and on choosing that my page should go to another php file preferably without using a submit button -but i cant figure out what error is taking place as i the form doesnt process Would appreciate if someone could have a look and advise. I've deleted most of the html stuff so its easier to read. <? header("Cache-Control: public"); include ("../NEWDBS/include/session.php") ; include ("link.php"); //db info for DB2 $userid = $_SESSION['userid']; // works $usertype = $_SESSION['usertype']; // works if(!isset($_SESSION['userid'])){ echo "<center><font face='Calibri' size='2' color=red>Sorry, Please login and use this page </font></center>"; exit;} //echo $userid; //echo $usertype; //works; if($_POST['submit']){ $dbtype = $_POST['dbtype']; if ($dbtype == 'Text') { include "text.php"; // contains dbname info $section = 'Text'; } if ($dbtype == 'Indus') { include "indus.php"; // contains dbname , other info $section = 'Indus'; } if ($usertype == '7') { $userFile = 'sales.php'; } // there are other usertypes as well - not listed for now $successMessage .= 'Click <a href="'.$section.'/'.$userFile.'?Userid='.$userid.'"> here </a>to proceed to your options</font></center></p>'; print $successMessage; // instead of printing this i need to open up the file sales.php located at "Indus/sales.php/userid=01". //indus.php contains db connection info because this leads to a MOVE from one DB to another . //the problem is this comes at the top of the page even before the submit button has been clicked ?> <html> <head> <meta http-equiv=Content-Type content="text/html; charset=windows-1252"> <meta name=Generator content="Microsoft Word 11 (filtered)"> <title>SELECTIONS</title> </head> <body lang=EN-IN link=blue vlink=purple> <div class=Section1> <form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post"> <input type="hidden" name="userid" value="<? echo $userid ?>"> <table class=MsoTableClassic2 border=1 cellspacing=0 cellpadding=0 style='border-collapse:collapse;border:none'> <tr style='height:1.0cm'> <td width=29 valign=top style='width:17.4pt;border:solid #99CC00 3.0pt; border-bottom:none;background:#DBF9AB;padding:0cm 5.4pt 0cm 5.4pt;height: 1.0cm'> <p class=MsoNormal style='background:#BCE966'><b><span style='font-family: "Tw Cen MT";color:white;letter-spacing:1.0pt'> </span></b></p> </td> <td width=297 valign=top style='width:178.25pt;border-top:solid #99CC00 3.0pt; border-left:none;border-bottom:none;border-right:solid #99CC00 3.0pt; background:#BAF527;padding:0cm 5.4pt 0cm 5.4pt;height:1.0cm'> <p class=MsoNormal><b><span style='font-family:"Tw Cen MT";color:white; letter-spacing:1.0pt'>Select a Business Section <select name="dbtype"></span></b></p> </td> <? $typesArray = array (""=>"[select One]", "Indus"=>"Indus", "Text"=>"Text" ); foreach ($typesArray AS $key=>$value) { print '<option value="'.$key.'" '.(($dbtype == $key)? "selected" :"").'>'.$value.'</option>'; } ?> </select> <input name='submit' type='submit' value='Submit'> </form> <?php } else { ?> <FORM METHOD=post ACTION="<? echo $PHP_SELF ?>"> <select name="dbtype"> <?php $typesArray = array (""=>"[select One]", "Indus"=>"Indus", "Text"=>"Text"); foreach ($typesArray AS $key=>$value) { print '<option value="'.$key.'" '.(($dbtype == $key)? "selected" :"").'>'.$value.'</option>'; } ?> </select> </font></td></tr> <input name='submit' type='submit' value='Submit'> > </font></td> </tr> <input type="hidden" name="userid" value="<? echo $userid ?>" > </form> <?php } ?> } ?> </table> <p class=MsoNormal><b><span style='font-family:"Tw Cen MT";color:white; letter-spacing:1.0pt'> </span></b></p> </div> </body> </html> Link to comment https://forums.phpfreaks.com/topic/201657-error-in-php-self-form-submission/ Share on other sites More sharing options...
Asheeown Posted May 13, 2010 Share Posted May 13, 2010 Post the error. EDIT: If a blank screen is showing, turn on errors for PHP temporarily, even just to see this. Link to comment https://forums.phpfreaks.com/topic/201657-error-in-php-self-form-submission/#findComment-1057851 Share on other sites More sharing options...
swatisonee Posted May 15, 2010 Author Share Posted May 15, 2010 Found the error . Was calling the form twice. Thanks. Link to comment https://forums.phpfreaks.com/topic/201657-error-in-php-self-form-submission/#findComment-1058587 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.