2017-07-19 5 views
-1

Ich versuche, PHP-Formulare zu lernen, Daten eingeben, Ergebnisse auf einer grundlegenden HTML-Formularseite mit einer Schaltfläche auszugeben. Allerdings schickt es mich nicht zum richtigen PHP-Link und zeigt stattdessen einen kaputten Link 404 nicht gefunden, und es scheint, dass ich einige seltsame Encoding-Probleme auf Apache habe.seltsame Codierung Zeichen auf PHP-Formular

ich dies auch zu meinem Hosting hochgeladen, und ich erhalte weitere seltsame Codierung für die Verbindung, die einfach handle_calc.php

Die angeforderte URL /ââ,¬Å"handle_calc.phpâ benannt werden soll â € "wurde auf diesem Server nicht gefunden.

Irgendwelche Tipps, was muss geändert werden? Ich bin erstaunt, dass beide Umgebungen standardmäßig kein Grundform-PHP korrekt anzeigen.

html

<!doctype html> 
<html lang=“en”> 
<head> 
<meta charset=“utf-8”> 
<title>Product Cost Calculator</title> 
</head> 
<body> 

<div><p>Fill out this form to calculate the total cost:</p> 

<form action=“handle_calc.php” method=“post”> 

<p>Price: <input type=“text” name=“price” size=“5”></p> 

<p>Quantity: <input type="number" name=“quantity” size=“5” min=“1” 
value=“1”></p> 

<p>Discount: <input type=“text” name=“discount” size=“5”></p> 

<p>Tax: <input type=“text” name=“tax” size=“5”> (%)</p> 

<p>Shipping method: <select name=“shipping”> 
<option value=“5.00”>Slow and steady</option> 
<option value=“8.95”>Put a move on it.</option> 
<option value=“19.36”>I need it yesterday!</option> 
</select></p> 

<p>Number of payments to make: <input type="number" name="payments" size=“5” 
min=“1” value=“1”></p> 

<input type="submit" name="submit" value="Calculate!"> 

</form> 

</div> 

</body> 

</html> 

php:

<!doctype html> 
<html lang=“en”> 
<head> 
<meta charset=“utf-8”> 
<title>Product Cost Calculator</title> 

<style type=“text/css”> 
.number { font-weight: bold; } 
</style> 

</head> 
<body> 

<?php 

//get the values from the $_POST array 

$price = $_POST[‘price’]; 
$quantity = $_POST[‘quantity’]; 
$discount = $_POST[‘discount’]; 
$tax = $_POST[‘tax’]; 
$shipping = $_POST[‘shipping’]; 
$payments = $_POST[‘payments’]; 

//calculate the total: 

$total = $price * $quantity; 
$total = $total + $shipping; 
$total = $total - $discount; 

//determine tax rate 

$taxrate = $tax/100; 
$taxrate = $taxrate + 1; 

//factor in the tax rate: 
$total = $total * $taxrate; 

//calculate the monthly payments 
$monthly = $total/$payments 

//print out results 

print “<p>You have selected to purchase:<br> 
<span class=\”number\”>$quantity</span> widget(s) at <br> 
$<span class=\”number\”>$price</span>price each plus a <br> 
$<span class=\”number\”>$shipping</span>shipping cost and a <br> 
<span class=\”number\”>$tax</span>percent tax rate.<br> 
After your $<span class=\”number\”>$discount</span>discount, the total cost 
is $<span class=\”number\”>$total</span>.<br> 
Divided over <span class=\”number\”>$payments</span>monthly payments, that 
would be $<span class=\”number\”>$monthly</span> each.</p>”; 

?> 

</body> 
</html> 
+1

zumindest den Formularcode – rtfm

+0

sicher zeigen. dachte, es war nicht die Codierung, die das Problem war. krank revidieren Sie jetzt – Wilson

+0

seit seiner Live (?) eine URL zu sehen, wäre es toll, – rtfm

Antwort

1

Ihr Formular action-Attribut wird mit Sonderzeichen, anstatt Standard doppelte Anführungszeichen. Sie scheinen überall Sonderzeichen zu verwenden. Ersetzen Sie alle Vorkommen dieser speziellen Zeichen durch normale doppelte/einfache Anführungszeichen.

+0

Hm, so komisch, dass mein Texteditor kaum einen Unterschied zeigt. Ich habe keine Ahnung, wie das passiert. Ich denke, ich brauche einen neuen Texteditor. lol. danke – Wilson

+0

@Wilson - Versuch notepad ++, Persönlich benutze ich Eclipse PDT – ArtisticPhoenix