Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-30-2012, 09:54 AM   PM User | #1
HDRebel88
Regular Coder

 
Join Date: May 2011
Posts: 112
Thanks: 11
Thanked 5 Times in 5 Posts
HDRebel88 is an unknown quantity at this point
including specific data from another file

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.

Be sure to turn Javascript off:
http://beta.area51entertainment.co/signup

Here's what I'm trying to do:

PHP Code:
        <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 Code:
<?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.
[/quote]
HDRebel88 is offline   Reply With Quote
Old 05-30-2012, 12:06 PM   PM User | #2
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,689
Thanks: 158
Thanked 2,184 Times in 2,171 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
Quote:
$content.= include 'signup.php';
You need to use file_get_contents() to get the content of the file into a string.
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
abduraooft is offline   Reply With Quote
Old 05-31-2012, 01:06 AM   PM User | #3
HDRebel88
Regular Coder

 
Join Date: May 2011
Posts: 112
Thanks: 11
Thanked 5 Times in 5 Posts
HDRebel88 is an unknown quantity at this point
Quote:
Originally Posted by abduraooft View Post
You need to use file_get_contents() to get the content of the file into a string.
If I do that though, I will get a string of the entire file right? So then I need to come up with some function to run through the string and find the specific data. Or would there be some way to convert the string back into proper a PHP file that isn't a string, and maintains the functionality of the if/else statements and the variables in the included file?
HDRebel88 is offline   Reply With Quote
Old 05-31-2012, 02:41 AM   PM User | #4
HDRebel88
Regular Coder

 
Join Date: May 2011
Posts: 112
Thanks: 11
Thanked 5 Times in 5 Posts
HDRebel88 is an unknown quantity at this point
nevermind


Using this:

PHP Code:
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.

Last edited by HDRebel88; 05-31-2012 at 03:00 AM..
HDRebel88 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:52 PM.


Advertisement
Log in to turn off these ads.