Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    May 2011
    Posts
    124
    Thanks
    12
    Thanked 6 Times in 6 Posts

    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]

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,851
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    $content.= include 'signup.php';
    You need to use file_get_contents() to get the content of the file into a string.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Regular Coder
    Join Date
    May 2011
    Posts
    124
    Thanks
    12
    Thanked 6 Times in 6 Posts
    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?

  • #4
    Regular Coder
    Join Date
    May 2011
    Posts
    124
    Thanks
    12
    Thanked 6 Times in 6 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •