A Flash Developer Resource Site

Page 2 of 7 FirstFirst 123456 ... LastLast
Results 21 to 40 of 126

Thread: PHP not working?

Hybrid View

  1. #1
    Junior Member
    Join Date
    Nov 2008
    Posts
    2

    Unhappy Help!

    Hey Guys and Girls,

    Im new to all this forum discussion thing so go easy on me please :P

    anywhos, im currently studying IT and our brief wants us to design and create a website, me being good with site design i found it easy, until my online php application failed to work, keep getting an blank screen when i load it up:

    (Asterix's are hiding my email from spambots just so you know)

    <?php
    function clean($data) {
    $data = trim(stripslashes(strip_tags($data)));
    return $data;
    }
    $exploits = "/(content-type|bcc:|cc:|document.cookie|onclick|onload)/i";
    foreach ($_POST as $key => $val) {
    $c[$key] = clean($val);

    if (preg_match($exploits, $val)) {
    exit("<p>No exploits, please!</p>");
    }
    }

    $show_form = true;
    $error_msg = NULL;

    if (isset($c['submit'])) {
    if (empty($c['name']) || empty($c['email']) || empty($c['comments'])) {
    $error_msg .= "Name, e-mail and comments are required fields. \n";
    } elseif (strlen($c['name']) > 50) {
    $error_msg .= "The name field is limited at 15 characters. Your first name will do! \n";
    } elseif (!ereg("^[A-Za-z' -]", $c['name'])) {
    $error_msg .= "The name field must not contain special characters. \n";
    } elseif (!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,6})$",strtolower($c['email']))) {
    $error_msg .= "That is not a valid e-mail address. \n";
    }

    if ($error_msg == NULL) {
    $show_form = false;

    if (!empty($c['Other Contact']) && !ereg("^(http|https)", $c['Other Contact'])) {
    $c['url'] = "Other Contact:" . $c['Other Contact'];
    }

    $subject = "Online Application";

    $message = "Online Application Form:";
    foreach ($c as $key => $val) {
    $message .= ucwords($key) . ": $val \n";
    }
    $message .= "IP: {$_SERVER['REMOTE_ADDR']} \n";
    $message .= "Browser: {$_SERVER['HTTP_USER_AGENT']}";

    if (strstr($_SERVER['SERVER_SOFTWARE'], "Win")) {
    $headers = "From: chris@5*******";
    $headers .= "Reply-To: {$c['email']}";
    } else {
    $headers = "From: Online Application Form <chris@************> \n";
    $headers .= "Reply-To: {$c['email']}";
    }

    $recipient = "chris@***********";

    if (mail($recipient,$subject,$message,$headers)) {
    echo "<p>Your mail was successfully sent.</p>";
    } else {
    echo "<p>Your mail could not be sent this time.</p>";
    }
    }
    }
    if (!isset($c['submit']) || $show_form == true) {
    function get_data($var) {
    global $c;
    if (isset($c[$var])) {
    echo $c[$var];
    }
    }

    if ($error_msg != NULL) {
    echo "<p><strong style='color: red;'>ERROR:</strong><br />";
    echo nl2br($error_msg) . "</p>";
    }
    ?> <p>Online Application TEST FOR CHRIS'S IT WORK!</p>
    <p>*Indicates Mandatory Field</p>
    <form action="" method="post">
    <p>FULL Name
    <label>
    <input type="text" name="name" id="name" value="<?php get_data("name"); ?>" />
    </label>
    </p>
    <p>Email Address
    <label><input type="text" name="email" id="email" value="<?php get_data("email"); ?> donthaveemail@dont_have_email.com" />
    </label>
    </p>
    <p>Telephone Number
    <label>
    <input type="text" name="telephoneNumber" id="Other Contact" value="<?php get_data("telephoneNumber"); ?>" />
    </label>
    </p>
    <p>Where did you hear about the election?
    <label><input type="text" name="reasonForapplication" id="subject" value="<?php get_data("reasonForapplication"); ?>" />
    </label>
    </p>
    <p>Referance No.1
    <textarea name="References" id="references"><?php get_data("references"):?>
    </textarea>
    </p>
    <p>Why You Think You Should Be Elected:

    <label>
    <textarea name="Manifesto" cols="70" rows="20" id="manifesto"><?php get_data("manifesto"); ?>
    </textarea>
    </label>
    <br />
    <input type="submit" name="submit" id="submit" value="Send" />
    </p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    </form> <p>
    <?php
    }
    ?>

  2. #2
    Senior Member unicycle's Avatar
    Join Date
    Mar 2000
    Posts
    254
    Quote Originally Posted by 55chris2303
    Hey Guys and Girls, Im new to all this forum discussion thing so go easy on me please :P
    Hi, I'm old but back after a long time.
    I'm not going to be hard on you, but also I'm not going to find where your poroblem is. But try:
    PHP Code:
    error_reporting(E_ALL); 
    at the very first line of your script.
    it should prevent
    Quote Originally Posted by 55chris2303
    getting an blank screen
    Or -if your HTTP-server is Apache- you can also put this debug switch in a .htaccess file
    Code:
    # php_value display_errors Off
    php_value display_errors On
    just some other tips:
    PHP Code:
    <?php
    $recipient 
    "chris@asteriskguru*com";
    // and
    if (mail($recipient,$subject,$message,$headers)) { }
    // In case you use variables only once...
    // then I would put those field as hard as possible, so:
    if (mail("[email protected]"$subject$message$headers)) { }
    // but also counts for $subject and especially $headers
    ?>

    // Lack of an defined action parameter will usually default on the script itself.
    <form action="" method="post">
    // But with "" as value, I would not rely on that. so maybe:
    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">

  3. #3
    Senior Member
    Join Date
    Sep 2000
    Posts
    128
    thanks for the help but I'm going to have to leave the flash form off the site as I can't get any response other than 'unauthorised domain'.
    Shame that.

  4. #4
    Junior Member
    Join Date
    Dec 2001
    Posts
    11

    Email Form working/not working

    Hi there,
    I have an email form movie with a php script which works perfectly as a standalone swf.
    The problem arise when I import the form into my website movie and make it a movie symbol, which I subsequently drag into another page and at this stage the form stops working. Must be something simple I have overlooked.
    Any ideas? Help appreciated.

    Jan
    Jappe

  5. #5
    Member
    Join Date
    Oct 2002
    Location
    Belgium
    Posts
    47
    I thought this was an easy thing to do, when you have the right software...
    In flash you create a form, naming all entree textboxes you want to send (assign 'var' values to them => 'sendto', 'subject', 'message' )
    When this is finished, create a button to send and to clear the form.
    I don't think I have to explain how to do this.

    Code for the Send button :
    Code:
    getURL("www.domain.com/sendmail.php", "_blank", "POST");
    Note : the sendmail.php file has to be on the same server as the flashmovie that contains the mailform. It won't work otherwise!

    code for sendmail.php :
    PHP Code:
    $sendto $_POST["sendto"];
    $subject $_POST["subject"];
    $message $_POST["message"];
    $send mail$sendto$subject$message)
    if(
    $send)
    {echo 
    "Your mail has been send succesfully";} 
    hope this helps a bit...
    --== A Flash N00B ==--
    http://www.avaweb.be

  6. #6
    Junior Member
    Join Date
    Dec 2004
    Posts
    24
    sybersnake! great post. It was so helpful to me. now I understand POST and what it does. I made a highScores thingy thanks to you! :-*

  7. #7
    Junior Member
    Join Date
    Jun 2003
    Posts
    22

    Getting vars from url into flash, then back into php

    Hi all,

    I'm having trouble understanding/implementing the use of vars in flash/php. I'm sucesfully loading dynamic text and jpegs from mysql using php. However, there's one piece that I can't figure out...any help is appreciated.

    What I want to do is pass a var to a page that contains my movie, such as www.site.com/index.php?id=4 - No prob so far.

    Then, I need my movie to pick up that var and pass it on to the script I'm using to load text from the db. Currently, my dyn text is coming from something like www.site.com/script.php - That script is looking for a var, but can't find it because flash hasn't sent it.

    I thought at first that it would pick up the variable sent in the URL, but it doesn't, because the URL I'm using to my script doesn't contain the var. How do I do this? How can I get that var (id=4) into the php script that loads my text?

    Here's the big pic if you want it. User comes to site, and uses an hmtl form to enter a code. That code ($id) is passed to the page that has the movie in it...and what I want it to do is serve up the text from the db record associated with the id used in the form. I'm missing something somewhere, and losing the var.

    Thanks for any help you can give...hope this makes sense
    Last edited by atsphpflash; 07-11-2003 at 05:21 PM.
    atsphpflash

  8. #8
    Registered User
    Join Date
    Feb 2001
    Posts
    13,039
    Hi,

    since the var is known before the flash is even loaded, you can use the
    <embed src="movie.swf?ID=3" ....>
    or
    <embed src="movie.swf" flashvars="ID=3" ...>
    method. The latter requires something like FP 6.0.50 ... so you should change that part in your html embedding

    Musicman

  9. #9
    Junior Member
    Join Date
    Jun 2003
    Posts
    22
    Musicman -

    I'm not sure if I understand your comments...the var isn't really known, because it comes from a form...the "id" could be anything that the user inputs. Am I missing your point?

    Would the code actually look like:
    <embed src="movie.swf?ID=$id" ....>

    Also - in my movie, what does the url to my script need to look like for my dyn content? If I just have: www.site.com/script.php - a var won't really be passed on to that script, will it? (even if the var is in the URL where the movie is embedded)

    Would the URL in my actionscript need to be something like:
    www.site.com/script.php?id=$id (I tried that, but it didn't work). I'm soooo confused.
    atsphpflash

  10. #10
    Registered User
    Join Date
    Feb 2001
    Posts
    13,039
    Hi,

    if I understood you right, you have some page that allows you to select an ID, and then loads a different page.
    This page shows a flash movie. So at the time the page is loaded, the ID is known (in contrast to situations where a form in one frame of a frameset changes content of another frame)
    You would need an echo or print in your php, either
    <?
    echo "<embed src=\"movie.swf?ID=$id\" ...>";
    ?>
    or
    <embed src="movie.swf?ID=<? echo $id; ?>" ....>

    In the movie, all you need to do is use the var

    Musicman

  11. #11
    Junior Member
    Join Date
    Jun 2003
    Posts
    22
    Hi,

    Thanks for your help...I'm doing a poor job explaining, so let me try again.

    HTML input form allows users to input a userid code.
    That form takes user to this link:
    http://www.url.net/vision_sites/temp...serid=pfleming

    (Where userid equals whatever their input was)

    On that page is a movie that loads dynamic text. The URL being used in the actionscript to get that text currently looks like this:
    http://www.url.net/vision_sites/content1_1.php

    BUT - I need it to look something like this:

    http://www.url.net/vision_sites/cont....php?userid=pf

    (where the 'pf' is automatically inserted based upon the variable used on the index.php page above).

    The script (content1_1.php) that gets text from db is looking for the variable $userid, so the first example returns nothing, because no var [$userid] is actually passed to it. If I 'hard code' the second example into my movie, I get the results I want. But, of course, I don't want to hard code it, because it is dependant upon user's input.

    So, how do I get my actionscript to pick up the variable [$userid] from index.php (above) and pass that on to my script at: content1_1.php? I thought something like this would work:

    http://www.url.net/vision_sites/content1_1.php?userid=$userid - but it doesn't

    The script in my php looks like this, if it matters:

    <?

    (snip)

    // formulate and execute query
    $query = "SELECT content1_1 FROM content1 WHERE userid='$userid'";
    $result = mysql_query($query) or die("Error in query: " .
    mysql_error());

    // get row
    $row = mysql_fetch_object($result);

    // print output as form-encoded data
    echo ($row->content1_1);

    (snip)

    ?>


    Clear as mud?? Thanks for your help
    Last edited by atsphpflash; 06-13-2009 at 01:57 PM.
    atsphpflash

  12. #12
    Registered User
    Join Date
    Feb 2001
    Posts
    13,039
    Hi,

    it is two steps
    - put the userid part into your index.php (both embed src=... and param name=movie parts). This will make a userid variable available to actionscript.
    Now the actionscript can call the content.php with the added variable.
    loadVariables('content.php?userid='+escape(userid) , ....)

    Musicman

  13. #13
    Junior Member
    Join Date
    Jun 2003
    Posts
    22

    Close....

    Hi,

    Well, I've embedded the movies as suggested, and I've modified the actionscript like this:

    loadVariablesNum("http://www.url.net/vision_sites/content1_1.php?userid="+escape(userid), 0, "GET");

    The php script referenced above looks like this:
    <?
    // Conects db to flash for dynamic content
    // open connection to database
    include("settings.inc.php");
    $connection = mysql_connect($hostname, $username, $password) or die
    ("Unable to connect!");
    mysql_select_db("$database") or die ("Unable to select database!");

    // formulate and execute query
    $query = "SELECT content1_1 FROM content1 WHERE userid='$userid'";
    $result = mysql_query($query) or die("Error in query: " .
    mysql_error());

    // get row
    $row = mysql_fetch_object($result);

    // print output as form-encoded data
    echo "content1_1=" . urlencode($row->content1_1);

    // close connection
    mysql_close($connection);
    ?>

    But - still nothing....
    The PHP code above works, and outputs this:

    content1_1=this+is+a+userid+test

    Which is what I want....it just won't show up in my movie...

    Your help is much appreciated....what is going wrong????
    Last edited by atsphpflash; 06-13-2009 at 01:56 PM.
    atsphpflash

  14. #14
    Registered User
    Join Date
    Feb 2001
    Posts
    13,039
    Hi,

    as far as I can see the loadvariables call happens inside a movieclip. You should use
    loadVariablesNum('content1_1.php?userid=' + _root.userid, 0)
    to get the correct variable. Also, there is no need to specify GET at that point; this just means that all vars in the current timeline are sent to the server (at the moment this is some <p align...></p> stuff from an empty html textfield)

    Musicman

  15. #15
    Junior Member
    Join Date
    Jul 2002
    Posts
    20
    I'm having problems passing variables from Flash to PHP from a flash movie that has to be displayed within a frame. The variables pass correctly when the movie is in a regular html page with no frames, but they don't get to the php page when the flash is within a frame. I've checked our server config and we have PHP 4.3.2. The problem seems to be specific to PHP because I'm able to send the variables to perl cgis.

    Any idea what is going on here?

    Here's the actionscript to pass the variables:
    on (release) {
    myData=new LoadVars();
    myData.Variable1="Flash";
    myData.Variable2="is";
    myData.Variable3="driving";
    myData.Variable4="me";
    myData.Variable5="crazy!";

    myData.send('ApplicationRatings.php','_blank', 'POST');
    _root.gotoAndPlay(2);
    }

    Here's the PHP I'm using to get the variables:

    if (empty($_POST)){
    print("there aren't any post variables");
    print("<P>");
    }
    print ("What is POST going on here:".$_POST["Answer1Text"]."<br/>");
    while (list ($key, $value) = each ($HTTP_POST_VARS) ) {
    print "key=".$key.":".$value."<br/>";
    }

    Thanks
    -Kim

  16. #16
    Registered User
    Join Date
    Feb 2001
    Posts
    13,039
    Hi,

    can you post a link to your page?

    Musicman

  17. #17
    Member
    Join Date
    Apr 2003
    Location
    North East, MD
    Posts
    62

    having same problem

    having trouble with a larger project, but when experimenting, even this simple example won't work..

    Here is my AS:
    ------------------------------
    var myvars = new LoadVars();

    myvars.name = "steve";
    myvars.dogs = "kilby and cayenne";
    myvars.number = 2;

    getURL("http://fakester.50free.net/test/savevars.php?"+myvars.toString());

    stop();

    ------------------this works fine, but:

    myvars.send("http://fakester.50free.net/test/savevars.php",GET);

    ------------------doesnt work.

    php script:

    <?

    $name = $_GET['name'];
    $dogs = $_GET['dogs'];
    $number = $_GET['number'];

    $fp = fopen("newfile.file", "a") or die("Couldn't create new file");

    $numbytes = fwrite($fp,"added this text to the file".$name.$dogs.$number);

    fclose($fp);

    echo("$numbytes written to text file");
    ?>

  18. #18
    Registered User
    Join Date
    Feb 2001
    Posts
    13,039
    Hi,

    the AS manual puts the GET into position three of the params, after url and a target frame

    Musicman

  19. #19
    I Like To Flash in Public ;) thebluedragon's Avatar
    Join Date
    Aug 2001
    Location
    London, U.K
    Posts
    194
    Hey ppl please help me with my php,

    goto the below thread!

    Its really annoying me! PLease help


    http://www.flashkit.com/board/showth...hreadid=507336

    Blue Dragon

  20. #20
    imagination through stupidity
    Join Date
    Apr 2001
    Location
    P3X-3113
    Posts
    1,238
    yea, i noticed this when i setup my new IIS 6.0 Local Server.
    Nothing to see here, move along.

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center