user3125314
user3125314

Reputation: 21

Show the input data PHP

I'm used to using CIN, of C++, to get a input into a var... Its really EASY! So, I'm starting learn PHP. And, I'm testing show on the screen what the user input in a form. I know its a easy thing, but I am not achieving.

The form is in this file: - html5.html

<div id="form">
<form action="test.php" method="post" >
<label for="code"> Code </label> <br />
<input type="password" id="coded" name="code" /> <br /> <br />
<hr />
<select name="modo-log[]" id="choose">
<option class="select_mod" value="professor">Professor</option>
<option class="select_mod" value="student" selected="selected">Student</option>
<option class="select_mod" value="user">User</option>
<option class="select_mod" value="adm">Adm</option>
</select>
<hr />
<button> Entrar </button> 
</form>

And the PHP file: - test.php

<?php
$code = $_POST['code'];
echo "$code";

$type_entered = $_POST['modo-log'];
echo "$type_enterd";
?>

But, I dont Know what I'm doing wrong... The page just gets blank.

Help me? Thanks.

Upvotes: 1

Views: 119

Answers (3)

user3125314
user3125314

Reputation: 21

I'm almost sure that my apache is wrong installed... It'snt possible! I cannot do a simple test!

When I suspected the trouble was the apache, I tryed only this:

<!DOCTYPE html>
<html>
<body>

<?php 
$varr_1 = 1;
$varr_2 = 2;
$varr_3 = $varr_1 + $varr_2;
echo $varr_3;
?>

</body>
</html>

And I didn't got any result. The page gets blank yet.

thanks to those who tried to help, I'll create a website on 000webhost to run php, whereas I've already tryed reinstalling the apache. I'm sad.... Bye

Upvotes: 0

Reshad
Reshad

Reputation: 2652

This following setup should tell you whats wrong :)

<?php
  ini_set('display_errors', 1);
  error_reporting(E_ALL);
 ?>

<div id="form">
<form action="" method="post" >
<label for="code"> Code </label> <br />
<input type="password" id="coded" name="code" /> <br /> <br />
<hr />
<select name="modo-log[]" id="choose">
<option class="select_mod" value="professor">Professor</option>
<option class="select_mod" value="student" selected="selected">Student</option>
<option class="select_mod" value="user">User</option>
<option class="select_mod" value="adm">Adm</option>
</select>
<hr />
<button type="submit">Entrar</button>
</form>


<?php var_dump($_POST); ?>

Upvotes: 0

Roopendra
Roopendra

Reputation: 7762

Add type="submit" attribute in <button> tag. SO that it will submit your form request

Change

  <button> Entrar </button> 

to

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

Upvotes: 1

Related Questions