jrobles Posted October 26, 2009 Share Posted October 26, 2009 I have an include that processes the log in form for located at the header of every page. The problem is, when it comes to my contact page now I have two forms. So when i process the contact form the header form is checked because the page is sending a post. Is there away that I can use the code below but only have it look at one particular form, so when any other forms are processed it ignores them? $_SERVER[REQUEST_METHOD]=='POST' Quote Link to comment https://forums.phpfreaks.com/topic/179098-_server/ Share on other sites More sharing options...
Daniel0 Posted October 26, 2009 Share Posted October 26, 2009 You could use the name of the submit button or you could add a hidden field. By the way, check out the manual's section on arrays. Particularly, I'm thinking on the part where it tells how to access indices in arrays. Quote Link to comment https://forums.phpfreaks.com/topic/179098-_server/#findComment-944939 Share on other sites More sharing options...
jrobles Posted October 26, 2009 Author Share Posted October 26, 2009 not sure i follow your solution. How do i use the $_SERVER code with the hidden field? Quote Link to comment https://forums.phpfreaks.com/topic/179098-_server/#findComment-945011 Share on other sites More sharing options...
mrMarcus Posted October 26, 2009 Share Posted October 26, 2009 not sure i follow your solution. How do i use the $_SERVER code with the hidden field? don't worry about the $_SERVER[REQUEST_METHOD]=='POST' .. as Daniel said, simply use unique submit names for each form: login form in header ...form stuff; <input type="submit" name="login_header" value="Login" /> contact form ...contact form stuff; <input type="submit" name="contact_form" value="Contact Us" /> Quote Link to comment https://forums.phpfreaks.com/topic/179098-_server/#findComment-945018 Share on other sites More sharing options...
mrMarcus Posted October 26, 2009 Share Posted October 26, 2009 and, are both forms being processed by the same include file? Quote Link to comment https://forums.phpfreaks.com/topic/179098-_server/#findComment-945029 Share on other sites More sharing options...
jrobles Posted October 27, 2009 Author Share Posted October 27, 2009 no, the login form is being processed by the include which does some cURL stuff. The contact form has a quick if statement that says: if (!$_POST['submit']) {show form} else {process mail form} I tried using if (!$_POST['login']) on my login include instead of if($_SERVER[REQUEST_METHOD]=='POST') but that screwed with my include and caused an error a few lines down Quote Link to comment https://forums.phpfreaks.com/topic/179098-_server/#findComment-945389 Share on other sites More sharing options...
Daniel0 Posted October 27, 2009 Share Posted October 27, 2009 [...] and caused an error a few lines down When asking people for help when getting an error, it's often a good idea telling what the error is. Quote Link to comment https://forums.phpfreaks.com/topic/179098-_server/#findComment-945391 Share on other sites More sharing options...
jrobles Posted October 27, 2009 Author Share Posted October 27, 2009 sorry, I suck at life... this is my error: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/vg001web02/68/11/3001168/web/dev/bsp/includes/login.inc.php on line 6 I am not sure why its looking for mysql data because the login form has not been submitted yet. This error happens right off the back regardless of what page I am on. Here are the first 15 lines of login.inc.php <? //if($_SERVER[REQUEST_METHOD]=='POST') if (!$_POST['login']) { $sql="select * from products where id=$_POST[program]"; $program=mysql_fetch_assoc(mysql_query($sql)); //print_r($_POST); //print_r($program); $myAexxis=array( "q_system_key"=>$program[sitekey], "q_action"=>"CUST_AUTH", "q_cust_username"=>$_POST[username], "q_cust_password"=>$_POST[password] ); $myCust=new CRM; Quote Link to comment https://forums.phpfreaks.com/topic/179098-_server/#findComment-945409 Share on other sites More sharing options...
Daniel0 Posted October 27, 2009 Share Posted October 27, 2009 Right, that means your query failed, so you'll have to fix it. You could try echoing the query and see if it's generated correctly. You would also want to fix the SQL injection using mysql_real_escape_string, but that's unrelated to the error. Quote Link to comment https://forums.phpfreaks.com/topic/179098-_server/#findComment-945419 Share on other sites More sharing options...
jrobles Posted October 27, 2009 Author Share Posted October 27, 2009 Thanks a million for your help. I see the that the query is running but I have not submitted the form yet so it should not do anything until i hit the login button Quote Link to comment https://forums.phpfreaks.com/topic/179098-_server/#findComment-945426 Share on other sites More sharing options...
mrMarcus Posted October 27, 2009 Share Posted October 27, 2009 Thanks a million for your help. I see the that the query is running but I have not submitted the form yet so it should not do anything until i hit the login button the ! before the $_POST['login'] would say otherwise. that ! is like saying NOT: <?php if (!$_POST['login']) { //is saying, "if $_POST['login'] is NOT set, continue; ?> lose the ! and the code will only execute IF $_POST['login'] has been set, and everything should be fine. <?php if (isset ($_POST['login'])) { ?> EDIT: see why posting your code and error(s) with a detailed description of what you are doing to get the error is crucial in getting help sooner than later. Quote Link to comment https://forums.phpfreaks.com/topic/179098-_server/#findComment-945432 Share on other sites More sharing options...
jrobles Posted October 27, 2009 Author Share Posted October 27, 2009 damn, that worked like a champ. those little details always get me. Thanks a million for your help guys Quote Link to comment https://forums.phpfreaks.com/topic/179098-_server/#findComment-945435 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.