0

I am trying to make a callback function for my website. I have seen a few PHP scripts but I am having trouble linking the script to the input text boxes. My PHP script is called callback.php. This is my HTML code:

<form action="callback.php" method="post" accept-charset="utf-8">

        <label id="Name"><br><br><br><br>Name<br> 
            <input name="nameinput" type="text" style="width: 300px; height: 30px;" /> </label>

        <label id="Email"><br><br>Email Address<br> 
            <input name="emailinput" type="text" style="width: 300px; height: 30px;" />  </label>

        <label id="Number"><br><br>Phone Number<br> 
            <input name="numberinput" type="text" style="width: 300px; height: 30px;" />  </label>

        <label id="Subject"><br><br>Subject<br> 
            <input name="subjectinput" type="text" style="width: 300px; height: 30px;" /> </label>

        <label id="Question"><br><br>Question<br> 
            <input name="questioninput" type="text" style="width: 300px; height: 70px" />
            <br><br> </label>

        <input name="Submit" type="submit" value="submit" />

        </form>

I have my form and I have tried using other PHP scripts and when I click the submit button on the form it acts as if it is a download. Does the script have to be on a .php page or can I incorporate it into the HTML and put it above the form?

9
  • Its should be in .php file if you are going to process the form action in the same file. Commented Mar 13, 2013 at 12:37
  • Looks like your server not support php, do you develop on localhost ? Commented Mar 13, 2013 at 12:37
  • 1
    If the PHP file downloads this usually means that your webserver cannot handle PHP files, create a PHP file called php.php and put <?php phpinfo(); ?> and see if that either downloads, or displays a long page. Commented Mar 13, 2013 at 12:37
  • does the whole webpage have to be .php? Commented Mar 13, 2013 at 12:39
  • Every single page in which you want to use PHP. Commented Mar 13, 2013 at 12:39

1 Answer 1

1

If the page is being treated as a download, this means the server does not know how to serve the file. This may mean you don't have PHP installed or Apache may not be setup properly.

PHP can be in any file extension you want but Apache will need to know to process that extension with the PHP engine. For example (in .htaccess):

AddType application/x-httpd-php .html

This tells Apache to run the .html extension files with the PHP engine. The suggested way is to use mod_rewrite if you want the .html extension to show and keep PHP files with the .php extension.

HTML code can be mixed in with PHP code. I suggest reading up on the basics of PHP.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.