textbox = php variable? - php

I want to get value from php variable to review it in textbox
what I have to write in "value":
<input type="text" name="name3" size="25" maxlength="50" value=""> name:

<input type="text"
name="name3"
size="25"
maxlength="50"
value="<?php echo htmlspecialchars($variable); ?>">

<input type="text" name="name3" size="25" maxlength="50" value="<?php echo $variable; ?>">

Related

how send in html value of php to server?

I try send value of input to the server, but in server I receive NULL of variable front side:
<form method="POST" action="validationUploadEmployee.php" style="border:1px solid #ccc">
<div class="container">
<input type="number" placeholder="Enter ID" name="idW" value = '<?php echo "$idW"; ?>' disabled="disabled" required >
<input type="text" placeholder="Enter Full Name" name="name" value = '<?php echo "$nameE"; ?>' required>
<input type="email" placeholder="Enter Email" name="email" value='<?php echo "$emailE"; ?>
<input type="text" placeholder="Enter Password" name="psw" value='<?php echo "$passwordE"; ?>' maxlength="10" size="8" required>
<input type="text" placeholder="Repeat Password" name="psw-rpt" value='<?php echo "$passwordE"; ?>' maxlength="10" size="8" required>
<input type="number" placeholder="Enter Number Phone" name="phone" value='<?php echo "$phoneE"; ?>' required>
<input type="text" placeholder="" name="branch" value='<?php echo "$myBranch"; ?>' disabled="disabled" required>
server side I receive variable like that:
$idW=$_POST['idW'];//id worker
Thank you.

how to process values from a form using PHP

I'm able to display the values but my problem is to get the values from the form... This block occurs 6 times (0-41) and they have the same name so i can access/validate them using javascript. ($weeks= $_POST['wt11'];)
<input class="chgcolor" type="text" name="wt10" value="1" disabled/> /*week 1*/
<input type="text" name="wt11" id="w01" onchange="CheckCols('0')" readonly maxlength="5" value="<?php echo $dayarray[0]; ?>" />
<input type="text" name="wt11" id="w01" onchange="CheckCols('1')" readonly maxlength="5" value="<?php echo $dayarray[1]; ?>" />
<input type="text" name="wt11" id="w01" onchange="CheckCols('2')" readonly maxlength="5" value="<?php echo $dayarray[2]; ?>" />
<input type="text" name="wt11" id="w01" onchange="CheckCols('3')" readonly maxlength="5" value="<?php echo $dayarray[3]; ?>" />
<input type="text" name="wt11" id="w01" onchange="CheckCols('4')" readonly maxlength="5" value="<?php echo $dayarray[4]; ?>" />
<input type="text" name="wt11" id="w01" onchange="CheckCols('5')" readonly maxlength="5" value="<?php echo $dayarray[5]; ?>" />
<input type="text" name="wt11" id="w01" onchange="CheckCols('6')" readonly maxlength="5" value="<?php echo $dayarray[6]; ?>" />
thanks.

FORM-TAG not work

i try to send this form-tag to my page customer.php but it doesn´t send a post to customer.php
in customer.php $_POST is always NULL
<form action="customer.php" method="POST">
<span id="MyCustomerDataHeader">MEINE KONTAKTDATEN</span><br><br><br>
<label class="MyCustomerDataLabel">Nachname:</label><input type="text" name="secondname" class="MyCustomerData" value="<?php print_r($query->getCustomerData()->secondname);?>"/><br>
<label class="MyCustomerDataLabel">Vorname:</label><input type="text" name="firstname" style="margin-left:15px;" class="MyCustomerData" value="<?php echo $query->getCustomerData()->firstname;?>"/><br>
<label class="MyCustomerDataLabel">E-mail:</label><input type="text" name="email" style="margin-left:30px;" class="MyCustomerData" value="<?php echo $query->getCustomerData()->email;?>" /><br>
<label class="MyCustomerDataLabel">Geburtstag:</label><input type="birthday" name="birthday" style="margin-left:-10px;" class="MyCustomerData" value="<?php echo $query->getCustomerData()->birthday;?>" /><br>
<label class="MyCustomerDataLabel">Handynummer:</label><input type="text" name="mobilephone" style="margin-left:-40px;" class="MyCustomerData" value="<?php echo $query->getCustomerData()->mobilephone;?>" /><br>
<label class="MyCustomerDataLabel">Stra&szlige:</label><input type="text" name="street" style="margin-left:15px;" class="MyCustomerData" value="<?php echo $query->getCustomerData()->street;?>" /><br>
<label class="MyCustomerDataLabel">Stadt:</label><input type="text" name="city" style="margin-left:30px;" class="MyCustomerData" value="<?php echo $query->getCustomerData()->city;?>" /><br>
<label class="MyCustomerDataLabel">Bundesland:</label><input type="text" name="federalestate" style="margin-left:-25px;" class="MyCustomerData" value="<?php echo $query->getCustomerData()->federalestate;?>"/><br>
<label class="MyCustomerDataLabel">Land:</label><input type="text" name="country" style="margin-left:30px;" class="MyCustomerData" value="<?php echo $query->getCustomerData()->country;?>"/><br>
<input type="submit" id="myCustomerDataButton" name="deleCustomer" style="font-size:14pt;margin-top:-5px;" value="ACCOUNT LÖSCHEN" />
</form>

Incorrect parameter count in the call to native function 'SHA1'

Trying to get an edit page to work and im getting this error Incorrect parameter count in the call to native function 'SHA1'. The error is only on the SHA1. everything else works fine other then this error. Any helped is greatly appreciated. I don't want the password showing or the encryption that is to stay blank as it is an admin editing a staff members details and they dont need to know the password.
<?php
if(empty($_POST['submit'])) {
$query = "SELECT * FROM user WHERE user_id = '$_GET[id]'";
// $supplier_id = $_GET['supplier_id'];
$result = mysqli_query($dbc, $query);
$row = mysqli_fetch_array($result);
}
else{
$update = "UPDATE user SET
title= '$_POST[inputtitle]',
first_name ='$_POST[inputfirst_name]',
middle_name = '$_POST[inputmiddle_name]',
last_name = '$_POST[inputlast_name]',
gender = '$_POST[inputgender]',
email = '$_POST[inputemail]',
pass = SHA1($_POST[inputSHA1pass]);
car_make = '$_POST[inputcar_make]'
car_model = '$_POST[inputcar_model]',
prefer_car = '$_POST[inputprefer_car]',
car_age = '$_POST[inputcar_age]',
st_no = '$_POST[inputst_no]',
st_name = '$_POST[inputst_name]',
suburb = '$_POST[inputsuburb]',
state = '$_POST[inputstate]',
country = '$_POST[inputcountry]',
postcode = '$_POST[inputpostcode]',
WHERE user_id = $_POST[user_id]";
mysqli_query($dbc, $update) or die(mysqli_error($dbc));
echo "User has been modified!";
header("Location: view_user.php");
}
?>
<form action="<?php echo $_SERVER['PHP_SELF'].htmlspecialchars($_GET[‘id’]); ?>" method="POST">
<input type="hidden" value="<?php echo $supplier = $_GET['id']; ?>" name="supplier_id">
<p>Title:
<input type="text" name="inputtitle" size="20" maxlength="30"
value="<?php echo $row["title"]; ?>"/>
</p>
<p>First Name:
<input type="text" name="inputfirst_name" size="20" maxlength="30"
value="<?php echo $row["first_name"]; ?>"/></p>
<p>Middle Name:
<input type="text" name="inputmiddle_name" size="30" maxlength="100"
value="<?php echo $row["middle_name"]; ?>"/></p>
<p>Last Name:
<input type="text" name="inputlast_name" size="20" maxlength="30"
value="<?php echo $row["last_name"]; ?>"/></p>
<p>Gender:
<input type="text" name="inputgender" size="20" maxlength="30"
value="<?php echo $row["gender"]; ?>"/></p>
<p>Email:
<input type="text" name="inputemail" size="10" maxlength="5"
value="<?php echo $row["email"]; ?>"/>
</p><br>
<p>Password:
<input type="text" name="inputSHA1pass" size="30" maxlength="40"
value="<?php if (isset($_POST['pass'])) echo $_POST['pass']; ?>"/></p>
<p>Car Make:
<input type="text" name="inputcar_make" size="20" maxlength="30"
value="<?php echo $row["car_make"]; ?>"/></p>
<p>Car Model:
<input type="text" name="inputcar_model" size="20" maxlength="30"
value="<?php echo $row["car_model"]; ?>"/></p>
<p>Prefered Car:
<input type="text" name="inputprefer_car" size="20" maxlength="30"
value="<?php echo $row["prefer_car"]; ?>"/></p>
<p>Car Age:
<input type="text" name="inputcar_age" size="20" maxlength="30"
value="<?php echo $row["car_age"]; ?>"/></p>
<p>Street Number:
<input type="text" name="inputst_no" size="20" maxlength="30"
value="<?php echo $row["st_no"]; ?>"/></p>
<p>Street Name:
<input type="text" name="inputst_name" size="20" maxlength="30"
value="<?php echo $row["st_name"]; ?>"/></p>
<p>Suburb:
<input type="text" name="inputsuburb" size="20" maxlength="30"
value="<?php echo $row["suburb"]; ?>"/></p>
<p>State:
<input type="text" name="inputstate" size="20" maxlength="30"
value="<?php echo $row["state"]; ?>"/></p>
<p>Country:
<input type="text" name="inputcountry" size="20" maxlength="30"
value="<?php echo $row["country"]; ?>"/></p>
<p>Postcode:
<input type="text" name="inputpostcode" size="20" maxlength="30"
value="<?php echo $row["postcode"]; ?>"/></p>
<p>
<input type="submit" name="submit" value="Submit"/></p>
</form>
<?php
mysqli_close($dbc);
?>
<br>
<br>
</div>
<br>
<?php
include ('../includes/footer.php');
?>
A few things:
Check that $_POST['inputSHA1pass'] is not empty
Enclose $_POST[inputSHA1pass] in quote marks and curly braces: SHA1('{$_POST[inputSHA1pass]}'). SHA1() expects a string and will error without one
Look into prepared statements. As this code stands, it is wide open to SQL injection attacks as none of your passed data is checked for validity
Change the semi-colon to a comma in the SHA1 line
Finally, once the UPDATE query has been built, capture it and try running it directly on the database server. It should give you a more meaningful error message and make debugging easier

Pass PHP session variable into HTML form

I have session variables that are posted from a form on another php page, and I can echo them by using:
<?php $_SESSION['newsletterSignup'] = $_POST['newsletterSignup'];
echo "Email = ". $_SESSION['newsletterSignup'];
?>
But I can't seem to insert these into a HTML form field:
<input type="text" name="email" id="email" size="36" "value="<?php echo $_SESSION['newsletterSignup'];?>" class="text-input" onBlur="emailval()" />
This should work...the quote before value was probably screwing it up
<input type="text" name="email" id="email" size="36" value="<?php echo $_SESSION['newsletterSignup'];?>" class="text-input" onBlur="emailval()" />
you use
<input type="text" name="email" id="email" size="36" "value="<?php echo $_SESSION['newsletterSignup'];?>" class="text-input" onBlur="emailval()" />
A " to many. Here is the fix
<input type="text" name="email" id="email" size="36" value="<?php echo $_SESSION['newsletterSignup'];?>" class="text-input" onBlur="emailval()" />
Also, did you use session_start(); ?

Categories