ich eine Seite mit php machte die Klasse, um herauszufinden, durch Markierungen eingeben (LOL) sie sind nämlich index.php und php.php Wenn ich die Markierungen in Index-Seite eingeben, funktioniert alles superValidieren von POST-Wert
Aber wenn ich direkt in die php.php springe, kommt die Fail-Nachricht, IDK warum.
Und ich möchte es beheben.
index.php
<html>
<head>
<title>Know your grade</title>
<style type="text/css">
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}
input[type=number] {
-moz-appearance:textfield;
}
body{
height: auto;
max-width: 100%;
}
#abt{
opacity: 0.3;
-webkit-transition: opacity 2s;
transition-timing-function: ease;
text-shadow: 0.5px 0.5px blue;
}
#abt:hover{
opacity: 1;
}
#wn{
text-decoration: none;
color: black;
text-shadow: 0.5px 0.5px navy blue;
-webkit-transition: color 0.5s;
}
#wn:hover{
color:red;
}
#reset{
-webkit-transition: color 1s , background-color 1.5s;
}
#reset:hover{
color:blue;
background-color: yellow;
}
</style>
</head>
<body>
<h1 style="text-align:center;font-family:MS comic Sans">Whats your grade?</h1>
<div style="text-align:center;font-family:Georgia;">
<form type="text" method="post" action="php.php">
Enter Marks : <input id="marks" name="marks" min="0" step="0.5" type="number" placeholder=" marks " required="required" oninput="validity.valid||(value='')">
<input type="submit" value="Submit"><br><br>
<input type="reset" name="Reset" id="reset">
</form>
</div>
<br>
<br>
<br>
<p style="text-align:center">How to use this : Enter marks of a subject , Press Enter or Click submit and know your grade.</p>
<p style="text-align:center"><b>Note:</b> Maximum marks is 100 </p>
<div id="abt" style="bottom:0px;position:fixed;right:0px;margin-right:10px;margin-bottom:5px">
<span style="margin:0 auto;display:table;"><u>About</u></span><br>
Developer : <u>Srijan Mukhrjee</u><br>
Proposed on : <u>26-09-2016</u><br>
Completed on : <u>26-09-2016</u><br>
Version : <u>2.<span style="font-size: 10px">1</span></u> (Latest version)<br>
<span style="display: table;margin: 0 auto"><a href="Whatsnew.html" id="wn">(What's New)</a></span>
</div>
</body>
</html>
Php.php
<?php
error_reporting(E_ALL^E_NOTICE);
$Mymarks = $_POST['marks'];
$fail = "<h3>We are sorry to say that you failed with poor marks - work hard</h3>"."<h4>Improve yourself and try better next time</h4>"."<h4>Your marks is "."<span style='color:red'>".$Mymarks."</span>"." </h5>";
if($Mymarks >=92 && $Mymarks <=100){
echo "You have got A1 "."Your marks is ".$Mymarks;
}
elseif($Mymarks >=84 && $Mymarks <=91){
echo "You have got A2 "."<br>"."And your marks is ".$Mymarks ;
}
elseif($Mymarks >=76 && $Mymarks <=83){
echo "You have got B1 "."<br>"."And your marks is ".$Mymarks;
}
elseif($Mymarks >=68 && $Mymarks <=75){
echo "You have got B2 "."<br>"."And your marks is ".$Mymarks;
}
elseif($Mymarks >=60 && $Mymarks <=67){
echo "You have got C1 "."<br>Try better next time<br>"."And your marks is ".$Mymarks;
}
elseif($Mymarks >=52 && $Mymarks <=59){
echo "You have got C2 "."<br>Improve yourself<br>"."And your marks is ".$Mymarks;
}
elseif($Mymarks >=44 && $Mymarks <=58){
echo "You have got D1 "."<br>Improve yourself<br>"."And your marks is ".$Mymarks;
}
elseif($Mymarks >=36 && $Mymarks <=57){
echo "You have got E1 "."<br>Improve yourself<br>"."And your marks is ".$Mymarks;
}
elseif($Mymarks < 36){
echo $fail;
}
elseif($Mymarks > 100){
echo "You Entered Marks greater than 100";
}
?>
Wenn ich direkt die php öffnen, ohne die index.php zu gehen durch die Fail-Nachricht beobachtet wird
Wie kann ich fix es?
Denn wenn 'null' auf eine ganze Zahl zu vergleichen,' null' cast 'integer' bekommt geben Sie den Vergleich zu tun, und die int Besetzung von null, ist 0. Sie sollten $ _POST sicher' werden machen [ 'marks'] 'existiert mit' isset' und überprüft, dass es sich um einen numerischen Wert handelt, der möglicherweise 'is_numeric' verwendet. –
Für Anfänger sollten Sie nicht davon ausgehen, dass Ihre gewünschten '$ _POST' (oder' $ _GET') Parameter da sind, egal was passiert. Sie müssen validieren. – apokryfos
Alle Ihre Bedingungen sind abhängig von der Postvariable 'marks'. Wenn Sie keine Daten auf dieser PHP-Seite veröffentlichen, schlagen diese Bedingungen fehl. –