PHP code error HELP.

edited May 2008 in Internet & Media
guys guys need your help i'm stuck here..

<?
$error = "http://testmatch.com.sg/attacherror.htm";
if ($attachment == true) { require("attach.php"); } else { $_POST; }
?>
i actually wants this php to detects if there is a attachment attached in the form user submitted if not it will be redirected to the error html page.

Comments

  • edited May 2008
    Is this an upload script?

    Where is the first instance of the $attachment variable

    Also post the error your getting if any and explain in further detail what you want to do and how you have the forms set up. You gave very little information that we can use to help.
  • edited May 2008
    i have 3 files.
    1 - to send with attachment / attach.php
    2 - to check if there is an attachment in the form submitted / code i pasted.
    3 - form in html coding save in .htm

    the problem is there isn't any error message at all.
    what i wanted was if there is no attachement found in the form submitted it can either redirect to a error page i.e error.htm or to create a dialog box to warn of mandatory attachment to be attached along.
  • edited May 2008
    If your just checking for a blank form field why not just a simple null if statement

    if($_POST != "") { // you can also use $_GET if you choose
    // execute attached successful code
    } else {
    // Failed and display error
    }
  • edited May 2008
    ok i can call that up but i don't seems to be able to redirect the page to the error.htm?

    i place the checking codes in mailprocess.php

    so form.htm sends in info to mailprocess.php then to attach.php.
  • edited May 2008
    Use the header function to redirect.

    <code>header('Location: error.php');

    Be sure you put this before any html or output or you will get a "Header has already been sent error"
    </code>
  • edited May 2008
    Thanks that works!
Sign In or Register to comment.