Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm having trouble setting a HTML input text into a PHP variable $x. If I set $x to an image URL, my code seems to work. Now I want the user to input an URL instead of myself. I've tried using [value = "<?$x ?> ] and other variations of this inside of the input text tag but they didn't work. I've also tried using $image_source (my input name) inside of my PHP tags, but I just get errors instead.

I do not have a submit button because it refreshes my page, negating the PHP echo, so I changed it to a button. How can I put the user's input into a variable so that I can use it inside of my php tags?

<body>
    <form action = "metadata.php" method = "post" id = "meta_form">
        <input type = "text" name = "image_source" id = "image_source" />
        <input type = "button" value = "Check" id ="submit_button" onclick = "check();"/>
    </form>
    <?php
        $photo_data = exif_read_data($x);
        echo $photo_data['FileName'];
    ?>
</body>
share|improve this question
add comment

2 Answers

Have you added $x = $_POST['image_source']; to your PHP script? You should also keep your submit button, if not nothing will be sent to the server

share|improve this answer
add comment

Extending on Marcelo's answer, it looks like you are not accessing the POST variable correctly.

If you are using $image_source to get the POST data, you will require Register Globals to be enabled on the server.

As stated in the PHP Manual, it is highly recommended not to use this featuere due to security concerns as well as the feature is deprecated in PHP 5.3 and removed in PHP 5.4

In your case, you would want to use $_POST['image_source'] (alternatively $_REQUEST['image_source']) to access the POST data for that text box.

If you are having further issues, check to see that your usage of exif_read_data is correct or if there is any error checking / validation checking you want to perform before echoing it.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.