HDFilmMaker2112 Posted May 30, 2012 Share Posted May 30, 2012 I need to pull in specific data under if/else statement in another file. The data is pulled via AJAX to create a dynamic form, but I'm also trying to pull the same data to create a static form for people without javascript enabled. So they would click a link and reload the entire page instead of a radio button and AJAX. The AJAX is trigger via signup.php?ajax&signup_type=$form_type. Right now the else statement is triggering and I am getting the base form to display. But if I add ?signup_type=music to the URL, nothing shows up other than the elements that are already hard coded into the primary page. Be sure to turn Javascript off: http://beta.area51entertainment.co/signup Here's what I'm trying to do: <noscript>'; if($_GET['signup_type']=="music"){ $form_type="music"; $content.= include 'signup.php'; } else{ $content.= include 'signup.php'; } $content.=' </noscript> Here's signup.php <?php if($form_type=="music"){ $content2.='Test'; } elseif($form_type=="film"){ $content2.='Test2'; } elseif($form_type=="business"){ $content2.='Test3'; } elseif($form_type=="other"){ $content2.='Test4 G'; } else{ $year_menu=generateBirthYearMenu(date("Y")); $day_menu=generateBirthDayMenu(null,null); $content2.='<div class="register_form_wrapper"> <p class="register_form_position"> <label for="register_email"><span class="register_form_text">Email:</span></label> <input type="email" value="'.$_SESSION['register_email'].'" name="register_email" id="register_email" class="register_form" /> </p> <p class="register_form_position"> <label for="register_fname"><span class="register_form_text">First Name:</span></label> <input type="text" value="'.$_SESSION['register_fname'].'" name="register_fname" id="register_fname" class="register_form" /> </p> <p class="register_form_position"> <label for="register_lname"><span class="register_form_text">Last Name:</span></label> <input type="text" value="'.$_SESSION['register_lname'].'" name="register_lname" id="register_lname" class="register_form" /> </p> <p class="register_form_position"> <label for="register_check_email"><span class="register_form_text">Re-enter Email:</span></label> <input type="email" value="'.$_SESSION['register_check_email'].'" name="register_check_email" id="register_check_email" class="register_form" /> </p> <p class="register_form_position"> <label for="register_password"><span class="register_form_text">New Password:</span></label> <input type="password" value="'.$_SESSION['register_password'].'" name="register_password" id="register_password" class="register_form" /> </p> <p class="register_form_position"> <label for="register_check_password"><span class="register_form_text">Re-enter Password:</span></label> <input type="password" value="'.$_SESSION['register_check_password'].'" name="register_check_password" id="register_check_password" class="register_form" /> </p> <p class="register_form_position_gender"> <label for="register_gender">Gender:</label> <select name="register_gender" id="register_gender"> <option value=""></option> <option value="Female">Female</option> <option value="Male">Male</option> </select> </p> <p class="register_form_position_birthday"> Birthday: <select name="register_month" id="register_month" onchange="sndReq(register_year.value,this.value);"> <option value="">Month</option> <option value="January">January</option> <option value="February">February</option> <option value="March">March</option> <option value="April">April</option> <option value="June">June</option> <option value="July">July</option> <option value="August">August</option> <option value="September">September</option> <option value="October">October</option> <option value="November">November</option> <option value="December">December</option> </select> <select name="register_day" id="register_day"> <option>Day</option>'."\n". $day_menu .'</select> <select name="register_year" id="register_year" onchange="sndReq(this.value,register_month.value);"> <option>Year</option>'."\n". $year_menu .'</select> </p> </div>'; } if(isset($_GET['ajax'])){ echo $content2; } return $content2; ?> I tried using a full URL with the query string directly in an include, and my webhost has that kind of include turned off. Link to comment https://forums.phpfreaks.com/topic/263369-including-specific-data-from-another-file/ Share on other sites More sharing options...
HDFilmMaker2112 Posted May 31, 2012 Author Share Posted May 31, 2012 solved. Link to comment https://forums.phpfreaks.com/topic/263369-including-specific-data-from-another-file/#findComment-1349984 Share on other sites More sharing options...
HDFilmMaker2112 Posted May 31, 2012 Author Share Posted May 31, 2012 Using this: if($_GET['signup_type']=="music"){ $_GET['form_type']="music"; $content.= include 'signup.php'; } does work. I was just trying to use the wrong URL. I was using signup?signup_type=$form_type should have been signup/?signup_type=$form_type. Forgot the slash. Link to comment https://forums.phpfreaks.com/topic/263369-including-specific-data-from-another-file/#findComment-1349986 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.