Echo to another file

Discussion in 'PHP' started by piri00, Jun 10, 2010.

  1. #1
    Hi I am learning php and I have script which works just what I need to do is I have two files
    one is form.php and second process.php in process.php I use capatcha image security code
    and when people type incorrect code it echo "Wrong security code!" but in process.php page.
    What i need to do I want to echo that message in form.php

    That is actually question how to echo something in one file from another file?

    Thank you for help
     
    piri00, Jun 10, 2010 IP
  2. dabaR

    dabaR Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You have to identify the error in one file, then redirect to the other file with http://ca3.php.net/manual/en/function.header.php and include the fact that there was an error either with a cookie (http://ca3.php.net/manual/en/function.setcookie.php), session variable (http://ca3.php.net/manual/en/features.sessions.php), or a URL parameter (redirect to form.php?error=1), and then in the form.php you would check for that indication of an error, and display an appropriate message if an error is found.

    That's how it can be done.
     
    dabaR, Jun 10, 2010 IP
  3. piri00

    piri00 Peon

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks done it :)
     
    piri00, Jun 10, 2010 IP
  4. idpremium

    idpremium Guest

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    nice quick information :)
     
    idpremium, Jun 10, 2010 IP
  5. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #5
    Basically you need to embedded the PHP Code before html part of the code to display the data in the same files so the job will be simpler and quicker now
    If you use include or something it will become a two way process! :)
     
    roopajyothi, Jun 10, 2010 IP
  6. iama_gamer

    iama_gamer Active Member

    Messages:
    404
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #6
    well i don't think changing the order will help this one!
    He seems to be doing all the validation on process.php so the form will have action="process.php" ...

    He seems to have solved it using header(location...) . Ajax might have been the other way to validate on the same page before actually processing the form.
     
    iama_gamer, Jun 11, 2010 IP
  7. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #7
    Yeah right Ajax can also be used to Process the Results!
     
    roopajyothi, Jun 11, 2010 IP