d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > N Help For Php Homework > Check Input Of Formular With $_get
Add Reply New Topic New Poll
Member
Posts: 3,579
Joined: Feb 1 2009
Gold: 400.50
Mar 8 2015 11:27am
Hey guys,

i need help how to check if my formular inputs are correct and if they are wrong, they should be displayed in red at the next page.
Here are my documents:

index.php --> here i do all my inputs and send it to form-02.php

<form action="form-02.php" method="get" enctype="text/plain">
<fieldset>
<legend>Personendaten</legend>
<table border="0" width="20%">
<tr align="center">
<td>Anrede:</td>
<td>
<select name="anrede">
<option value="Herr">Herr</option>
<option value="Frau">Frau</option>
</select>
</td>
</tr>

<tr align="center">
<td>Vorname:</td>
<td><input type="text" name="vorname" /></td>
</tr>

<tr align="center">
<td>Nachname:</td>
<td><input type="text" name="nachname" /></td>
</tr>

<tr align="center">
<td>E-mail:</td>
<td><input type="text" name="email" /></td>
</tr>

<tr align="center">
<td>Straße:</td>
<td><input type="text" name="straße" /></td>
</tr>

<tr align="center">
<td>PLZ:</td>
<td><input type="text" name="plz" /></td>
</tr>

<tr align="center">
<td>Ort:</td>
<td><input type="text" name="ort" /></td>
</tr>

<tr align="center">
<td><input type="submit" name="submit" value="Abschicken"/></td>
</tr>

</table>
</fieldset>
</form>

form-02.php --> here the inputs should be displayed AND I SHOULD DISPLAY ALL WRONG INPUTS FROM INDEX.php IN RED

<form action="form-03.php" method="get" enctype="text/plain">
<fieldset>
<legend>Personendaten</legend>
<table border="0" width="20%">
<tr align="center">
<input type="hidden" name="anrede" id="anrede" value="<?php echo $_GET['anrede']; ?>">
<td><?php echo $_GET['anrede']; ?>
</tr>

<tr align="center">
<input type="hidden" name="vorname" id="vorname" value="<?php echo $_GET['vorname']; ?>">
<td><?php echo $_GET['vorname']; ?></td>
</tr>

<tr align="center">
<input type="hidden" name="nachname" id="nachname" value="<?php echo $_GET['nachname']; ?>">
<td><?php echo $_GET['nachname']; ?></td>
</tr>

<tr align="center">
<input type="hidden" name="email" id="email" value="<?php echo $_GET['email']; ?>">
<td><?php echo $_GET['email']; ?></td>
</tr>

<tr align="center">
<input type="hidden" name="straße" id="straße" value="<?php echo $_GET['straße']; ?>">
<td><?php echo $_GET['straße']; ?></td>
</tr>

<tr align="center">
<input type="hidden" name="plz" id="plz" value="<?php echo $_GET['plz']; ?>">
<td><?php echo $_GET['plz']; ?></td>
</tr>

<tr align="center">
<input type="hidden" name="ort" id="ort" value="<?php echo $_GET['ort']; ?>">
<td><?php echo $_GET['ort']; ?></td>
</tr>

<tr align="center">
<td><input type="submit" name="submit" value="Abschicken"/></td>
</tr>

</table>
</fieldset>
</form>

form-03.php --> i think var_dump says all on it

<?php
var_dump($_GET["anrede"]);
var_dump($_GET["vorname"]);
var_dump($_GET["nachname"]);
var_dump($_GET["email"]);
var_dump($_GET["straße"]);
var_dump($_GET["plz"]);
var_dump($_GET["ort"]);
?>


It would be really helpfull if someone can help me in that case.

regards,
diablopago

This post was edited by DiabloPago on Mar 8 2015 11:28am
Member
Posts: 29,723
Joined: Jun 11 2007
Gold: 279.52
Mar 8 2015 10:59pm
what do you mean all wrong inputs? empty inputs or?

and that first for should be posting not getting.

method="post"
Member
Posts: 3,579
Joined: Feb 1 2009
Gold: 400.50
Mar 9 2015 05:31am
For example.

Name input, should be only string --> akuuz is correct
If i type akuuz678 and send it, 678 should be displayed red because it is wrong
Member
Posts: 3,579
Joined: Feb 1 2009
Gold: 400.50
Mar 9 2015 04:51pm
Someone know it?
Member
Posts: 29,723
Joined: Jun 11 2007
Gold: 279.52
Mar 9 2015 06:32pm
Quote (DiabloPago @ Mar 9 2015 11:31am)
For example.

Name input, should be only string --> akuuz is correct
If i type akuuz678 and send it, 678 should be displayed red because it is wrong


not possible in that sense, the input forms are going to make everything a string, also because php doesnt have strong datatypes.

if you want to strip out numbers i suggest you looking into regular expressions.

This post was edited by AkuuZ on Mar 9 2015 06:34pm
Member
Posts: 3,579
Joined: Feb 1 2009
Gold: 400.50
Mar 10 2015 04:29am
Okay.
Is it also possible with javascript?
Member
Posts: 6,481
Joined: Jul 5 2009
Gold: 0.70
Mar 10 2015 09:15am
Quote (DiabloPago @ Mar 10 2015 06:29am)
Okay.
Is it also possible with javascript?


Yes, you need javascript/jQuery to add that level of client side validation
Member
Posts: 3,579
Joined: Feb 1 2009
Gold: 400.50
Mar 11 2015 02:17am
Quote (mebeatyou @ Mar 10 2015 03:15pm)
Yes, you need javascript/jQuery to add that level of client side validation


Okay thank you, i am going to try it
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll