I have a single page php application to generate an 8 digit number, user inputs a value and page generates another value, both values are inserted into mysql db and displaying the generated value in an input box at a single button click. Insertion is happening, but generated value is not displaying in the inputbox at the first time, I also tried session its not helping too.
here is my php code,
<?php
require_once __DIR__ . '/db_connect.php';
$db = new DB_CONNECT();
?>
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Untitled Document</title>
</head>
<body>
<div>
<?php
if(isset($_POST['luckyButton']) && $_POST['myLuckyNumber'] != ""){
//sleep(20);
$myLuckyNum = $_POST['myLuckyNumber'];
$resultmyLuckyNum = mysql_query("SELECT * FROM lucky where luckyNum='$myLuckyNum'") or die(mysql_error());
if (mysql_num_rows($resultmyLuckyNum) > 0) {
while ($rowmyLuckyNum = mysql_fetch_array($resultmyLuckyNum)) {
$generatedNumber = $rowmyLuckyNum["generatedNum"];
}
}else{
$gen = getGen();
$resultGenNum = mysql_query("INSERT INTO lucky (slno, luckyNum, generatedNum) VALUES ( NULL, '$myLuckyNum', '$gen')");
if (mysql_num_rows($resultGenNum) > 0) {
$generatedNumber = $gen;
}
}
}
?>
<form action="" method="post">
<input type="text"class="inputs" name="myLuckyNumber" onClick="this.select();" placeholder="Enter You Lucky Number" value="<?php echo $myLuckyNum; ?>" />
<input type="submit" class="css_button" name="luckyButton" value="Check"/>
</form>
</div>
<br><br><br>
<?php
if($generatedNumber != ""){
echo '<input type="text" name="myLuckyNumber" onClick="this.select();" id="generatedNumber" readonly="true" value="' . $generatedNumber . '" />';
}
echo '<p id="errText"> ' . $err . ' </p>';
function random_string($length) {
$key = '';
$keys = array_merge(range(0, 9));
for ($i = 0; $i < $length; $i++) {
$key .= $keys[array_rand($keys)];
}
return $key;
}
function getGen(){
$gen1 = random_string(8);
$result = mysql_query("SELECT * FROM lucky where generatedNum='$gen1'") or die(mysql_error());
if (mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_array($result)) {
if($row["generatedNum"] == $gen1){
getGen();
}
}
}else{
//echo $gen1;
return($gen1);
}
}
?>
</body>
</html>
my table,.
CREATE TABLE `lucky` (
`slno` int(11) NOT NULL,
`luckyNum` text NOT NULL,
`generatedNum` text NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
The problem with your code is that mysql_num_rows will return either 0 or 1, use it like
if($resultGenNum === 1){
$generatedNumber = $gen;
}
You are using mysql_num_rows in a wrong way. When you run insert query, it does not return rows, it returns true or false (Boolean). When it will return true, you will get 1 (as $resultGenNum).
use this instead:
if ($resultGenNum === 1){
$generatedNumber = $gen;
}
Instead of using if ( $generatedNumber != "" ), perhaps you should try something like if ( isset( $generatedNumber ) ).
If $generatedNumber doesn't exist (which it doesn't if nothing was posted to the script), then the comparison will fail (in fact, you're probably getting a PHP error).
Of course, that leads us to the next problem - if nothing is posted to the script, you don't generate a number. So of course, if you don't generate a number, there is no number to display. So you should structure your code in such a way that a random number is always generated - regardless of whether a post variable was received or not.
Related
I'm posting a select option from one page to another, on my actual server code (PHP), I'm wanting to firstly, get the POST name, for example, $_POST['selection_value'] and secondly, check if it's equal to a value from the selection, like : if($_POST['selection_value'] == 'time') {} . (time is the value of a selection option). How would I go about doing this ?
My code for the POST grab :
The markup
<div class="form-group" style="padding-left: 4%;">
<div class="form-group m-r-12">
<label class="col-sm-12 control-label";">Add User</label>
</div>
<input type="text" name="username" id="username" placeholder="Username" class="form-control" required />
<input type="text" name="email" id="email" placeholder="Email" class="form-control" required />
<input type="text" name="cpukey" id="cpukey" placeholder="CPUKey" class="form-control" required />
<button onclick="addUser()" class="btn btn-success"><i class="fa fa-user-plus"></i> Add User</button>
<select class="form-control" id="selection_value" name="selection_value">
<option value="account_credits">Account Credits</option>
<option value="free_gifted_credits">Free Gifted Credits</option>
<option value="time">Member Server Days</option>
</select>
<input type="text" name="add_to_all_value" id="add_to_all_value" placeholder="Value to add to current" class="form-control" required />
<button id="button1" onclick="add_to_all()" class="btn btn-primary"><i class="fa fa-user-plus"></i> Add To All Users</button>
The AJAX
function add_to_all() {
myOutput = document.getElementById('add_user_result');
var member_selection = $('#selection_value :selected').text()
var member_value = $('#add_to_all_value').val();
if(member_selection != "" & member_value != "") {
$.ajax ({
type: "POST",
url: 'includes/ajax_data_add_to_all.php',
data: { selection: member_selection, value: member_value },
success:function(response) {
$("#add_user_result").show();
$('#add_user_result').fadeOut(3000).html(response);
header('Location: admin_members.php');
},
error: function() {
$("#add_user_result").show();
$('#add_user_result').fadeOut(3000).html(response);
header('Location: admin_members.php');
}
});
} else {
$("#add_user_result").show();
$('#add_user_result').fadeIn(3000).fadeOut(3000);
myOutput.innerHTML = "<font style='color: red;'>You must fill in all the blanks.</font>";
}
return false;
}
Now my code for the add time (server code) :
function grab_all_time() {
global $con;
$usersTime = "SELECT time FROM users";
$result = $con->query($usersTime) or die("Error");
while ($row = mysqli_fetch_assoc($result)) {
return $row['time'];
}
}
$AllusersTime = grab_all_time();
if(!empty($_POST) && isset($_POST)) {
$selection = mysqli_real_escape_string($con, $_POST['selection']);
$value = mysqli_real_escape_string($con, $_POST['value']);
$membersDate = new DateTime($AllusersTime);
$membersDate->add(new DateInterval('P'.$value.'D'));
$finishedDT = $membersDate->format('Y-m-d') . "\n";
if($selection == 'Member Server Days') {
$insert_query = mysqli_query($con, "UPDATE users SET '".$selection."' + '".$value."'");
if($insert_query) {
echo '<font style="color: green;">Successfully Added to all users</font>';
echo '<META HTTP-EQUIV="Refresh" CONTENT="3; URL=admin_members.php">';
}
else {
echo '<font style="color: red;">Failed to add to all users</font>';
echo '<META HTTP-EQUIV="Refresh" CONTENT="3; URL=admin_members.php">';
}
} else {
$insert_query = mysqli_query($con, "UPDATE users SET time = '".$finishedDT."'");
if($insert_query) {
echo '<font style="color: green;">Successfully Added to all users</font>';
echo '<META HTTP-EQUIV="Refresh" CONTENT="3; URL=admin_members.php">';
}
else {
echo '<font style="color: red;">Failed to add to all users</font>';
echo '<META HTTP-EQUIV="Refresh" CONTENT="3; URL=admin_members.php">';
}
}
To return all records for the query in your function grab_all_time you could use an array, add each result to it and return that array:
function grab_all_time() {
global $con;
$usersTime = "SELECT time FROM users";
$result = $con->query($usersTime) or die("Error");
$results = array();
while( $row = mysqli_fetch_assoc($result) ) {
$results[]=$row['time'];
}
return $results;
}
That obviously returns an array so you can't simply assign the return value as a DateTime object which you later go on to do. If it is just the one result from the query you need to process then why fetch all rows?
if( $_SERVER['REQUEST_METHOD']=='POST' && isset( $_POST['selection'], $_POST['value'] ) ){
$selection = mysqli_real_escape_string( $con, $_POST['selection'] );
$value = mysqli_real_escape_string( $con, $_POST['value'] );
$AllusersTime = grab_all_time();
foreach( $AllusersTime as $i => $time ){
$membersDate = new DateTime( $time );
$membersDate->add( new DateInterval('P'.$value.'D') );
$finishedDT = $membersDate->format('Y-m-d') . "\n";
/* .... the rest of you code .... */
/* dont add the `meta refresh` */
}
}
Still a trifle confused with what you actually wish to do - hopefully I have understood correctly in that you wish to update each user's record according to values and options selected. To update each record individually using pre-existing content in each of their records using a where clause for the update statement would seem logical.
I think my confusion stems from the sql that retrieves data from the users table in your function. The way it was originally structured meant that despite selecting all records you returned only the first one in the recordset and used that as the basis for the remaining code. If, and I say IF, you intended to return ALL records and process them individually then returning an array from your function seems the best option.
You will note I modified ( again ) your function to also get the user_id associated with each record - substitute that for the correct column name.
function grab_all_time() {
global $con;
/* NOTE: assumed a column `user_id` !! */
$usersTime = "SELECT `user_id`,`time` FROM `users`;";
$result = $con->query($usersTime) or die("Error");
$results = array();
while( $row = mysqli_fetch_assoc($result) ) {
/* NOTE: assumed column `user_id` !! */
$results[ $row['user_id'] ]=$row['time'];
}
return $results;
}
if( $_SERVER['REQUEST_METHOD']=='POST' && isset( $_POST['selection'], $_POST['value'] ) ){
$selection = mysqli_real_escape_string( $con, $_POST['selection'] );
$value = mysqli_real_escape_string( $con, $_POST['value'] );
$AllusersTime = grab_all_time();
$results = array();
foreach( $AllusersTime as $user_id => $time ){
$membersDate = new DateTime( $time );
$membersDate->add( new DateInterval('P'.$value.'D') );
$finishedDT = $membersDate->format('Y-m-d');
/* .... the rest of you code .... */
if( $selection == 'Member Server Days' ) {
$sql='update `users` set `'.$selection.'`=`'.$selection.'` + '.$value.' where `user_id`="'.$user_id.'";';
} else {
$sql='update `users` set `time`="'.$finishedDT.'" where `user_id`="'.$user_id.'";';
}
$results[ $user_id ]=mysqli_query( $con, $sql ) ? 'Success' : 'Fail';
}
echo '<pre>',print_r( $results, true ),'</pre>';
echo '<META HTTP-EQUIV="Refresh" CONTENT="3; URL=admin_members.php">';
}
Im in this page: website.php?page=5 and in this page I have this form:
<form method="POST" action="website.php?page=<?php echo $pagenumber; ?>">
<input type="text" name="goto" />
<input type="submit" name="submit" value="goto" />
</form>
If I write something like 3 into the text field and press the goto button (if isset.... my php code get the number and upload into the $pagenumber var)
But the new page isn't the website.php?page=3 what I want. The new page is website.php?page= (there is no number) .and if I press again then goes it to the right page.
I think in the first press when i do the $pagenumber isn't declared. Only when i press second.
How can I fix it? I must use this way i cant use session, cookie etc.
<?php if(isset($_POST['submit']))
{
$kitkeresek = $_POST['goto'];
$becsuletemw = "SELECT * FROM adatok WHERE nev = '$kitkeresek'";
$becsuletem2w = mysql_query($becsuletemw);
while( $becsuletem3w = mysql_fetch_array($becsuletem2w))
$becsuletemw = $becsuletem3w["becsulet"];
$valllamiw = mysql_query("SELECT becsulet FROM adatok WHERE becsulet > '$becsuletemw' ");
$rowsw = mysql_num_rows( $valllamiw );
$kitkeresekw = $rowsw + 1 ;
$intvizsgalat= $kitkeresekw/10;
if (is_int($intvizsgalat))
{ $pagenumber = $intvizsgalat - 1 ; }
else
{$pagenumber = floor($kitkeresekw/10); } ;
}
?>
When you do this :
$intvizsgalat= $kitkeresekw/10;
$intvizsgalat is float, even if the result is int, because it is the result of a division.
You can try var_dump($intvizsgalat) to confirm
try something like this:
$floatParts = $intvizsgalat - floor(intvizsgalat);
if ($floatParts == 0) {
//
} else {
//
}
Ok, I'm really stuck. But I think I'm headed in the right direction. the script that calls this script has multiple fields which are generated dynamically by PHP. I need some way of looping through them and checking if they're set to avoid any undefined variables, and then once I know that they're all set and checked for validity inserting them into the MySQL table passwords. I could really use your help on this one guys.
<?php
require_once('/session/session.php');
require_once('auth/auth.php');
require_once('/MySQLi/mysqliConnect.php');
require_once('check_fields_function.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<!-- Copyright 2015 Brock Lynch -->
<?php $page = "passwords"; ?>
<?php require_once('/headerFooter/docHead.php'); ?>
<body>
<?php require_once('/headerFooter/header.php');?>
<div id="boxWrapper"> <!-- beginning of boxWrapper -->
<?php require_once('question_nav.php'); ?>
<div id="display_categories">
<?php
// This is just for reference: check_fields($pattern,$post,$minlength,$maxlength,$name_of_field)
$numOfFields = $_POST['numOfFields'];
for($z = 1;$z <= $numOfFields;$z++) {
if(isset($_POST['password_input$z']) && isset($_POST['group_input$z']) && isset($_POST['belongs_input$z']) && isset($_POST['name_input$z']) && isset($_POST['choice$z'])) {
$password[$z] = check_fields("/([[:alnum:]\!\#\#\$\%\^\&\*\*\(\)\-\_\+\=\[\]\;\'\:\"\'\<\>\?\/\`\~])+/",$_POST['password_input$z'],6,50,'Password$z');
$password_group[$z] = check_fields("/^[a-zA-Z \'\"]+$/",$_POST['group_input$z'],1,50,'Password Group$z');
$password_belongs_to[$z] = check_fields("/^[a-zA-Z \'\"]+$/",$_POST['belongs_input$z'],1,50,'Belongs To$z');
$password_name[$z] = check_fields("/^[a-zA-Z \'\"]+$/",$_POST['name_input$z'],1,50,'Password Name$z');
$changes_periodically[$z] = check_fields("/^[0-1]+$/",$_POST['choice$z'],1,50,'Changes Periodically$z');
}
else {
$password[$z] = false;
$password_group[$z] = false;
$password_belongs_to[$z] = false;
$password_name[$z] = false;
$changes_periodically[$z] = false;
}
}
// Iterate through each array and if they are all set, set the master password_setting to true
function check_all_arrays($fieldArray)
{
global $numOfFields;
$p = 0;
if(isset($fieldArray)) {
foreach($fieldArray as $test) {
echo "Yeah, this seems to be working";
if($test == true) {
$p++;
}
}
}
else {
return false;
}
if($p == $numOfFields) {
return true;
}
else {
return false;
}
}
if(check_all_arrays($password) == true && check_all_arrays($password_group) == true && check_all_arrays($password_belongs_to) == true && check_all_arrays($password_name) == true && check_all_arrays($changes_periodically) == true) {
echo "Got passed master checks, this is good";
// Encrypt the users password before entering it into the database.
// Clean the data before inserting it into the database.
$instance = PasswordCrypt::createWithNewPassword($_POST['password_input']);
$password_pass = mysqli_escape_string($mysqli,$instance->encodePassword($_POST['password_input']));
$token_pass = mysqli_escape_string($mysqli,$instance->getToken());
$key_pass = mysqli_escape_string($mysqli,$instance->getKey());
$group = mysqli_escape_string($mysqli,$_POST['group_input']);
$belongs_input = mysqli_escape_string($mysqli,$_POST['belongs_input']);
$name_input = mysqli_escape_string($mysqli,$_POST['name_input']);
$password_save = "INSERT INTO passwords (password_id,customer_id,password_not_key,token_pass,key_pass,password_group,
changes_periodically,security_status,belongs_to,password_name)VALUES('','" . $_SESSION['customer_id'] . "','" . $password_pass . "','". $token_pass . "','" . $key_pass . "','" . $group . "','" . $choice . "','','" . $belongs_input . "','" . $name_input . "')";
mysqli_query($mysqli,$password_save) OR DIE(mysqli_error($mysqli));
// Echo confirmation message to user
echo "<div style='text-align:center;'>You have successfully stored 1 password</div>";
?>
<form action="myPassword.php">
<button input="submit_back">Back</button>
</form>
<?php
}
else {
// Tell them to use only letters in fields besides the password field.
echo "<div style='text-align:center;'>All fields are required except changes periodically. Password field may have letters, numbers, and special characters and must be at least 6 characters. All other fields may only have letters. Thank you</div>";
?>
<form action="myPassword.php">
<button type="submit">Go Back</button>
</form>
<?php
}
?>
</div> <!-- End of display categories -->
</div> <!-- End of boxWrapper div -->
</body>
<div class="bigBoldFont"></div>
<?php require_once('headerFooter/footer.php'); ?>
</div><!-- end of boxWrapper -->
</body>
</html>
What you have now will work if you change the single quotes on all the $_POST variables to double quotes.
E.g. change isset($_POST['password_input$z']) to isset($_POST["password_input$z"])
You could also make it a little easier to read by wrapping the variable in curly braces {}. isset($_POST["password_input{$z}"])
I'm making a simple guestbook script in php. I pretty much have it finished but need help finding the logic errors in my code. One is that when echoing the results from the form content. I am wanting to display the email, whole name and comment, each on different lines.
like this
email: some#email.com
Name: joe somebody
Comment:
hello world.
but for some reason it just displays the first and last name on all lines.
the other 3 issues are sorting(ascending, descending) and removing duplicates.
Thanks in advance for your advice on how to fix this.
I just ask you be detailed so i know what you are talking about.
In any case, heres the code:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Guest Book</title>
</head>
<body>
<?php
// is there data in the fields
if (isset($_POST['submit'])){
$firstName = addslashes($_POST['first_name']);
$lastName = addslashes($_POST['last_name']);
$wholeName = $firstName . "," . $lastName;
$email = addslashes($_POST['email']);
$comment = addslashes($_POST['comment']);
$guestRecord = "$wholeName~$email~$comment\n";
$guestBook = fopen("guestbook.txt", "ab");
//if not let the user know
if ($guestBook === FALSE)
echo "There was an error saving your entry!\n";
else {
// if there is info add it to the txt file
fwrite($guestBook, $guestRecord);
// close the txt file
fclose($guestBook);
//let the user know info was saved
echo "Your entry has been saved.\n";
}
}
?>
<h2>Enter your name to sign our guest book</h2>
<hr>
<form method="POST" action ="GuestBook1.php">
<p>First Name<input type ="text" name="first_name"/></p>
<p>Last Name<input type ="text" name="last_name"/></p>
<p>Email<input type ="text" name="email"/></p>
<p><textarea name="comment" id="comment"/></textarea></p>
<p><input type ="submit" value ="Submit" name="submit"/></p>
</form>
<hr>
<p>Show Guest Book
<br />
Delete Guest Entry
<br />
Remove Duplicate Entries
<br />
Sort Entries A-Z
<br />
Sort Entries Z-A
<br />
</p>
<?php
// if theres info in the form process info
if (isset($_GET['submit'])) {
if ((file_exists("guestbook.txt")) &&
(filesize("guestbook.txt") != 0)) {
$guestArray = file("guestbook.txt");
//switch to $_Get Method
switch ($_GET['submit']) {
// remove duplicate entries
case 'Remove Duplicates':
$guestArray = array_unique($guestRecord);
$guestArray = array_values($guestRecord);
break;
//sort ascending
case 'Sort Ascending':
$guestArray = sort($guestArray);
break;
//sort Decending
case 'Sort Decending':
$guestArray = ksort($guestArray);
break;
}
//count to see how many entries there are
if (count($guestArray)>0) {
$newGuest = implode($guestArray);
$guestStore = fopen("guestbook.txt", "ab");
if ($guestStore === false)
echo "There was an error updating the message file\n";
else {fwrite($guestStore, $newGuest);
fclose($guestStore);
}
}
else
unlink("guestbook.txt");}
}
if ((!file_exists("guestbook.txt")) ||
(filesize("guestbook.txt") == 0))
echo "<p>There are no entries.</p>\n";
else {
// there isnt anything in the txt file show an error
if ((!file_exists("guestbook.txt")) ||
(filesize("guestbook.txt") == 0))
echo "<p>There are no entries.</p>\n"; else {
//if there is information display the txt file in a table
$guestArray = file("guestbook.txt");
echo "<table style=\"background-color:lightgray\"
border=\"1\" width=\"100%\">\n";
//begin counting number of guest entries
$count = count($guestArray);
for ($i = 0; $i < $count; ++$i) {
$currMsg = explode("~", $guestArray[$i]);
// display results in a table
echo "<td width=\"5%\" style=\"text-align:center;
font-weight:bold\">" . ($i + 1) . "</td>\n";
echo "<td width=\"95%\"><span style=\"font-weight:bold\">
Email:</span> " . htmlentities($currMsg[0]) . "<br />\n";
echo "<span style=\"font-weight:bold\">Name:</span> " .
htmlentities($currMsg[0]) . "<br />\n";
echo "<span style=\"text-decoration:underline;
font-weight:bold\">Comment</span><br />\n" .
htmlentities($currMsg[0]) .
"</td>\n";
echo "</tr>\n";
}
echo "</table>\n";
}
}
?>
</body>
</html>
$firstName = addslashes($_POST['first_name'])."\r\n";
The \r\n\ will put things physically on a new line. Make sure to use double quotes.
Regarding your first issue, you are echoing $currMsg[0] for all of the fields. You need to use the correct index for each of the values (0 for name, 1 for email, 2 for comment). Or even better, use something like:
list($name, $email, $comment) = explode("~", $guestArray[$i]);
That way you have meaningful variable names.
The other issues you'll need to be more specific as to what you're trying to do (and in what way your current code isn't working).
I can see at least one issue though - your links have ?action= but your switch statement is looking at $_GET['submit'], not $_GET['action']. Plus you have a typo in case 'Sort Decending': (missing 's')
I am new to the world of PHP and have put together a form that multiplies an entered value. However when I attempt to validate if a person has not entered any values to return an error message, it does display the message. My code below. Appreciate if you could also suggest improvements.
<?php
$counter = 0;
if(isset($_POST["submit"])) {
$start = $_POST["start"];
$end = $_POST["end"];
$multiply = $_POST["multiplication"];
// if($_POST["start"] == "" && $_POST["end"] == "" && $_POST["multiplication"] == "") {
// print "Please enter some values";
// }
if(!isset($_POST["start"], $_POST["end"], $_POST["multiplication"])) {
print "Please enter some values";
}
// for($start;$start<$end;$start++) {
// $counter = $counter +1;
// $multiplication = $counter * $multiply;
// print "$counter <br />";
// print "$counter multiplied by $multiply = $multiplication <br />";
// }
}
?>
<html>
<head>
<title>Sample Multiplication</title>
</head>
<body>
<form name="multiply" method="post" action="multiplication_sample.php">
<input type="text" name="start" value="<?php if(isset($_POST["start"])) { print $start; } ?>">
<input type="text" name="end" value="<?php if(isset($_POST["end"])) { print $end; } ?>">
<input type="text" name="multiplication" value="<?php if(isset($_POST["multiplication"])) { print $multiply; } ?>">
<input type="submit" name="submit" value="submit">
</form>
<?php
if(isset($_POST["submit"])) {
for($start;$start<$end;$start++) {
$counter = $counter + 1;
$multiplication = $counter * $multiply;
print "$counter multiplied by $multiply = $multiplication <br />";
}
}
?>
</body>
</html>
I think that isset will make sure a variable is not NULL, however, "blank" is not the same as null. If you submit a form with blank values, the variable is still being set, it is just empty.
When the form is submitted, the content of the input fields is sent to the server.
If those input fields are empty, the server gets an empty string for each input -- but it gets something ; so, the $_POST["start"], $_POST["end"], $_POST["multiplication"] items are set -- even if they only contain empty strings.
You could check :
If the fields contain an empty string : if ($_POST["start"] === '')
Or if if contains only blank spaces : if (trim($_POST["start"]) === '')
Or if they are empty : if (empty($_POST["start"]))
If the fields aren't defined your code will print your message in the html before the <html> tag appears. Most browsers won't display it or display it in an unexpected place.
You should move the message display somewhere in the html where the user could see it.
And as other pointed out, except on the first call of the page the fields will have an empty value but still exists (and so isset will return TRUE)
I hope, I understand you right. It is
if(!isset($_POST["start"], $_POST["end"], $_POST["multiplication"])) {
print "Please enter some values";
}
that works not as expected? It seems, that you assume an empty string means, that nothing is set, what is not true.
$x = "";
isset($x); // true
Use empty() or just $_POST['start'] == '' instead.