I'm new to html and php and so on... Just self studying some things. Now I have a little problem with this form (inside of "auswahlmenue.php"):
<form action="liste.php" method="post">
Mitarbeiter
<select name="mitarbeiter">
<?php
// SQL-Query erzeugen
require "sql.php";
$sql01 = "SELECT NAME FROM felder ORDER BY name";
$result = mysql_query($sql01);
// für jeden Eintrag ein Option-Tag erstellen
while ($row = mysql_fetch_array($result)) {
echo '<option value="'.$row['ID'].'"'.($_POST['NAME'] == $row['ID'] ? " selected": "").'>'.$row['NAME'].'</option>';
}
?>
</select>
<input type="submit" value="Senden" />
</form>
Everything works fine. I see my dropdown list and I can select my name... Now I want to check my selection at this page (liste.php):
<?require "auswahlmenue.php";if(isset($_POST['mitarbeiter']) ) {$listemid=$_POST["mitarbeiter"];echo "Test $listenmid";}else {echo "Es wurden keine Werte übergeben";}?>
It doesn't print out my variable $listenmid... What am I getting wrong?
Thank you very much for your help...
Related
The existing code that I am working with provides a drop-down for the end
user to select a time zone.
My goal is to limit the choices down to
1. America
and
a. Option Eastern
value America/New_York
b. Option Central
value America/Chicago
c. Option Mountain DST
value America/Denver
d. Option Mountain no DST
value America/Phoenix
e. Option Pacific
value America/Los_Angeles
Narrowing it down to America was easy enough by simply commenting out the code.
Narrowing it down further to the 5 time zones is turning out to be beyond my pay grade.
Any advice?
$regions = [
# 'Africa' => DateTimeZone::AFRICA,
'America' => DateTimeZone::AMERICA,
# 'Antarctica' => DateTimeZone::ANTARCTICA,
# 'Aisa' => DateTimeZone::ASIA,
# 'Atlantic' => DateTimeZone::ATLANTIC,
# 'Europe' => DateTimeZone::EUROPE,
# 'Indian' => DateTimeZone::INDIAN,
# 'Pacific' => DateTimeZone::PACIFIC
];
$timezones = [];
foreach ($regions as $name => $mask) {
$zones = DateTimeZone::listIdentifiers($mask);
foreach ($zones as $timezone) {
$timezones[$name][$timezone] = $timezone;
}
}
$actualTimezone = JFactory::getSession()->get('user-timezone', $displayData['dateHelper']->getDate()->getTimezone()->getName(), 'Calendar');
?>
<form action="<?php echo JUri::base(); ?>" method="get" class="dp-timezone dp-form">
<span class="dp-timezone__label">
<?php echo $displayData['translator']->translate('COM_CALENDAR_CHOOSE_TIMEZONE'); ?>:
</span>
<select name="tz" class="dp-select dp-timezone__select">
<option value="UTC"<?php $actualTimezone == 'UTC' ? ' selected' : ''; ?>>
<?php echo $displayData['translator']->translate('JLIB_FORM_VALUE_TIMEZONE_UTC'); ?>
</option>
<?php foreach ($timezones as $region => $list) { ?>
<?php foreach ($list as $timezone => $name) { ?>
<option value="<?php echo $timezone; ?>"<?php echo $actualTimezone == $timezone ? ' selected' : ''; ?>>
<?php echo $displayData['translator']->translate($name); ?>
</option>
<?php } ?>
<?php } ?>
</select>
<input type="hidden" name="task" value="profile.tz" class="dp-input dp-input-hidden">
<input type="hidden" name="option" value="com_calendar" class="dp-input dp-input-hidden">
<input type="hidden" name="view" value="profile" class="dp-input dp-input-hidden">
<input type="hidden" name="return" value="<?php echo base64_encode(JUri::getInstance()->toString()); ?>" class="dp-input dp-input-hidden">
</form>
Can any one help me to integrate a form with PHPMailer. I have following form.
<form method="POST">
<p>Name:<input type="text" name="name" size="30"></p>
<p>Email Address:<input type="text" name="email" size="30"></p>
<input type="submit" name="submit" value="Submit">
</form>
I just need to display POST variables in my receiving email's body. I have search and refer alot and spend hours in it, everyone clarifies it with high level explanation. As i am not a programmer can anyone explain me how can i do this with simple explanation. I just done a method as follows but it did'nt work.
$name = $_POST['name'];
$email = $_POST['email'];
$mail->Body = "
<html>
<h2><b>".$name." ".$email."</b></h2>
</html>";
When i tried the above method i am getting error in this line '$name = $_POST['name'];'. The error message is: Notice: Undefined index:' I think i am wrong with my placing order of codes.
Thanks in advance!
<?php
if(array_key_exists("name",$_POST) && $_POST["name"] != "" && array_key_exists("email",$_POST) && $_POST["email"] != ""){
require 'mailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
//$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'mail#gmail.com'; // SMTP username
$mail->Password = 'mypassword'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
$mail->setFrom('mail#gmail.com', 'Manager');
$mail->addAddress('mail#gmail.com', 'Administrator'); // Add a recipient
$name = $_POST['name'];
$email = $_POST['email'];
$mail->Body = "<h2><b>".$name." ".$email."</b></h2>";
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
} else {
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<form method="POST">
<p>Name:<input type="text" name="name" size="30" required></p>
<p>Email Address:<input type="email" name="email" size="30" required></p>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
<?php
}
?>
There is a select2 element :
<select name="commande_id" id="commande">
<option value=""> -- Choisir une commande -- </option>
<option value="1">COM-2-2015</option>
</select>
$(document).ready(function() {
...
$("#commande").select2({width:'100%'});
...
});
When I enter the page in update mode then I set the option value of the select element programmatically to be the value from database :
$(document).ready(function() {
...
<?php
if (isset($data)) { ?>
...
$("#commande").val("<?php echo $data[0]['commande_id'];?>");
...
<?php
}
?>
...
});
The problem is that at runtime the select element does not show the appropriate text :
But when I click it then the appropriate value is selected :
So how to make the appropriate text shown ?
I don't know how you are getting the $data, but I guess it's something like that, just an example:
<?php
$data[] = ["commande_id" => "1", "name_field" => "COM-2-2015"];
foreach ($data as $key => $value){
?>
<select>
<option value='<?php echo $value['commande_id']?>'><?php echo $value['name_field'] ?></option>
</select>
<?php } ?>
Look it here: https://ideone.com/PSpKmu
I want to insert data into my fusion table which is public . I looked out at https://developers.google.com/fusiontables/docs/sample_code for help specifically http://code.google.com/p/fusion-tables-client-php/source/browse/trunk/samples/form_example.php . I downloaded the necessary files for this script to run i.e. downloaded clienlogin.php , file.php , sql.php and constants.php. The script is running but rows are not getting inserted and I am not able to find the reason . I have pasted my code ( its a small code .. please have a look at it and let me know the error I am commiting). Essentially I want to insert data into my fusion table after collecting user info through user forms . I don't want to use google forms. Any kind of help / pointers in this direction would be helpful.
<html>
<?php
include('D:\xampp\htdocs\itpold\clientlogin.php');
include('D:\xampp\htdocs\itpold\sql.php');
include('D:\xampp\htdocs\itpold\file.php');
// Table id
$tableid = 3544282;
//Enter your username and password
$username = "ABCD#gmail.com";
$password = "XYZ";
$token = ClientLogin::getAuthToken($username, $password);
$ftclient = new FTClientLogin($token);
// If the request is a post, insert the data into the table
if($_SERVER['REQUEST_METHOD'] == 'POST') {
// Insert form data into table
$insertresults = $ftclient->query(SQLBuilder::insert($tableid,
array('Name'=> $_POST['Name'],
'Location' => $_POST['Location'])));
$insertresults = explode("\n", $insertresults);
$rowid1 = $insertresults[1];
echo $rowid1 ;
}
?>
<head>
<title>Simple Form Example</title>
<style>
body { font-family: Arial, sans-serif; }
</style>
<script type="text/javascript">
// Simple form checking.
function check_form() {
if(document.getElementById('Name').value == '' ||
document.getElementById('Location').value == '') {
alert('Name and location required.');
return false;
}
return true;
}
</script>
</head>
<body >
<h1>Simple Form Example</h1>
<h2>Insert data</h2>
<form method="post" action="forms.php" onsubmit="return check_form();">
Name: <input type="text" name="Name" id="Name" /><br />
Result: <input type="text" name="Location" id="Location" /><br />
<input type="submit" value="Submit" />
</form>
<h2>Table data</h2>
<p>
<?php
// Show the data from table
$table_data = $ftclient->query(SQLBuilder::select($tableid));
$table_data = explode("\n", $table_data);
for($i = 0; $i < count($table_data); $i++) {
echo $table_data[$i] . '<br />';
}
?>
</p>
</body>
</html>
Often, the server is not able to send requests to secure URLs. See the following StackOverflow post for some ideas on how to fix the problem:
Can't connect to HTTPS site using cURL. Returns 0 length content instead. What can I do?
I suspect that this is a permissions problem with your table. Have you made sure that the account your are logging in with is set up as an editor for this table? The easiest way to check this is to go into Fusion Tables as the owner for the table, and click the share link in the upper right hand corner.
I am trying to make it so that this comment form on my wordpress website can not be submitted if the user does not enter enough data into the textarea.
I wrote this for the header
<script>
function CheckLength()
{
var msg_area = document.getElementById("Message");
msg_area.innerHTML = "";
if (document.getElementById("commentarea").value.length < 100) {
msg_area.innerHTML = "YOU DID NOT ENTER ENOUGH INFO FOR YOUR REVIEW";
}
else document.getElementById("commentform").submit();
}
</script>
And my form looks like this
<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" name="commentform" id="commentform">
<p><input size="36" type="text" name="author" /> Name <span class="required">*</span></p>
<p><input size="36" type="text" name="email" /> Email <span class="required">*</span> (Not Published)</p>
<p><input size="36" type="text" name="url" /> Website</p>
<p><input size="36" type="text" name="server_ip" id="server_ip" /> Server IP/Hostname</p>
<p><?php show_subscription_checkbox(); ?></p>
<p><textarea name="comment" id="commentarea" cols="100%" rows="20"></textarea></p>
<p align="right"><input type="button" name="submit" id="submit" value="Submit Review" tabindex="5" onClick="CheckLength()"></p>
<span id="Message" style="color:#ff0000"></span>
<input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" />
<?php /* do_action('comment_form', $post->ID); */ ?>
</form>
The form spits out the error "YOU DID NOT ENTER ENOUGH INFO FOR YOUR REVIEW" if I type in less then 100 chars, but if I type more then a 100 chars the form does not submit. If I change the input type to submit it does submit, but it doesn't matter if < 100
Change the name of your input button.
The error I get using your markup is that submit is not a function, because it thinks I'm referring to the submit button. The following should work:
<input type="button" name="submitbtn" id="submitbtn" value="Submit Review" tabindex="5" onClick="CheckLength()">
Could you do this?
Put the check in the "onsubmit" event for the form:
<form action="wp-comments-post.php" onsubmit="return CheckLength();" method="post" name="commentform" id="commentform">
You'll have to update you function to return a Boolean:
<script type="text/javascript">
function CheckLength()
{
var msg_area = document.getElementById("Message");
msg_area.innerHTML = "";
if (document.getElementById("commentarea").value.length < 100) {
msg_area.innerHTML = "YOU DID NOT ENTER ENOUGH INFO FOR YOUR REVIEW";
return false;
}
return true;
}
</script>
Then remove the onclick event from your submit button.
Can you try this?
<script>
function CheckLength()
{
var msg_area = document.getElementById("Message");
msg_area.innerHTML = "";
if (document.getElementById("commentarea").value.length < 100)
{
msg_area.innerHTML = "YOU DID NOT ENTER ENOUGH INFO FOR YOUR REVIEW";
return false;
}
else
{
document.getElementById("commentform").submit();
return true;
}
}
</script>