0

I make a simple app without any database in php .just simple post method when i write my input text field and submit it send me to another post and put that input data in that field where i want if work in xammp fine but on live server it show me nothing here is my codes.........

    <form action='show.php' method='POST'>
    <input type="text" size="30" value="Enter Your Course Code Like &nbsp 
     &nbsp  'CS101'..." name="text" >
    <button name="submit"></button>
    </form>

and my show.php code is

    <?php
        if(isset($_POST['submit'])){
            $N = $_POST["text"];
            echo '<a href="http://website.com/media/movie/'.$N.' MP4/'.$N.'_movie.mp4" class="styled-button-1">'.$N.'_movie</a>'; 
        }
    ?>

Where i am wrong?

Jay Blanchard
  • 34,243
  • 16
  • 77
  • 119
  • 1
    *where i am wrong?* I think this should help you out: http://php.net/manual/en/tutorial.forms.php and you will immediately see your error – Rizier123 Apr 21 '15 at 20:38
  • we have 3 codes, 1) one posted here 2) one working local with XAMPP. 3.) one not working on server. I'm pretty sure the error is to be found in the 3 different codes, we can not see. BTW there are spaces in the created link, not really good. Also `&nbsp` is not valid must be ` `. and useless in a inputline. – moskito-x Apr 21 '15 at 23:59

3 Answers3

1

add type <button name="submit" type="submit"></button>

Tip: Always specify the type attribute for a element. Different browsers use different default types for the element.

also remove name="submit"

Community
  • 1
  • 1
YesItsMe
  • 1,709
  • 16
  • 32
  • Why should the OP try this? Please add an explanation of what you did and why you did it that way not only for the OP but for future visitors to SO. – Jay Blanchard Apr 21 '15 at 20:43
  • Well it's pretty obvious. Without setting the type=submit it is not a submit button and is not getting submitted, no matter how much php you'll have waiting for it. – HaLeiVi Jun 02 '15 at 03:32
1

You used html element button. It is good choice if you want to add any event with javascript. But if you need to send form normal with backend, you need to use

<input type="submit" value="send" />

OR

<button type="submit">send</button>

the type="submit" mark button as submit form button. You ommited the type so you created only button element.
Equivalent for button is

<input type="button" value="Click me" onclick="msg()">

But button does'n invoke send form to the backend.

daremachine
  • 2,678
  • 2
  • 23
  • 34
0

I think $_POST['submit'] is not set because it doesn't have a value.

Change:

<button name="submit"></button>

To:

<button name="submit" value="1">Submit</button>

Usually you would use a type="submit", then to set the button text you use value:

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

And now $_POST["submit"] automatically has a value already.

Halcyon
  • 57,230
  • 10
  • 89
  • 128
  • not working ....i set button value .anyone of you please join me in team viewer please –  Apr 21 '15 at 20:52