html <select> --> no upload from selected statement - php

I am working on a form for a newsletter questionairy. There I have some trouble with some selected statements. The statements which can be selected (value="f" and value "m") will not be uploaded onto the mail server. Maybe someone of you has a solution. The FirstNAme, LAstName and EMail are working.
Here is the code:
<div style="margin-right:auto;margin-left:auto;width:720px">
<form id="nl2go--form" action="https://app.newsletter.com/de/recipients/index/subscribe/" method="post" accept-charset="utf-8">
<table border="0" align="center">
<tr>
<td><select name="n1go-gender" style="font-size:9pt; background:border: 1px solid #181717; padding: 2px; width: 45pt;" onchange="alert(this.form.n1go-gender.options[this.form.n1go-gender.selectedIndex].value)">
<option value="f" selected>Woman</option>
<option value="m">Mister</option>
</select> <input type="text" name="nl2go-firstname" id="nl2go--firstname" style="font-size:9pt; color:#181717; background:border: 1px solid #181717; padding: 2px; width: 107pt;" placeholder="FirstName"/> <input type="text" name="nl2go--lastname" id="nlgo-lastname" style="color:#181717; font-size:9pt; width:107pt; background border: 1px solid #181717; padding: 2px;" placeholder="LastName"/></td>
<tr>
<td><input type="text" name="nl2go-mail" id="nlgo--mail" style="font-size:9pt; width:272pt; background border: 1px solid #cccccc; padding: 2px;" placeholder="Your E-Mail"></td>
<tr>
<td align="center"><input type="submit" value="Senden" name="nlgo-submit" id="nlgo-submit" class="jfk-button jfk-button-action">
<input type="hidden" name="nl2go--key" id="nl2go--key" value="dfdfdfdf....."></div></td></tr></table></div></ol>
</form
cheers
Vrede

Ugly. You have syntax issues on this line:
</div></td></tr></table></div></ol>
Thus, breaking your code/form.
Also, try using classes for styling opposed to inline styles.

Related

Object not found XAMPP PHP error

I am trying to run a php file using xampp but I'm getting the Object not found error, I watched some videos where people say create another folder and run it under that but that is not working for me! look at the screenshot below and please if you could help me understand why this isn't working
enter image description here
Please note even if i use another file such as footer.php i get the same error.
here is the code for mens.php i didnt include it in the screenshot
<?php
session_start();
//unset($_SESSION['basket']);
?>
<!DOCTYPE html>
<html>
<head>
<!-- External Stylesheet -->
<link rel="stylesheet" href="style.css" type="text/css" />
<title>Mens</title>
</head>
<body>
<div class="bar">Sale Now On!</div>
<div id="outer">
<?php
include('header.php');
?>
<!-- All content will be wrapped insisde this container -->
<div id="container">
<!-- Page -->
<h2>Mens Clothing</h2>
<table width="100%" cellpadding="0" cellspacing="0">
<tr class="headings">
<th style="width: 20%;">Photo</th>
<th style="width: 30%;">Desciption</th>
<th style="width: 10%;">Size</th>
<th style="width: 10%;">Price</th>
<th style="width: 10%;">Qty</th>
<th style="width: 20%;">Action</th>
</tr>
<form action="addtocart.php" method="post" name="addtocart">
<tr class="datarow">
<td style="width: 20%; text-align: center; border-left:dotted
1px #333; border-bottom: dotted 1px #333; border-right:dotted 1px #333;">
<img src="img/suit.jpg" width="112px" />
</td>
<td style="width: 30%; text-align: center; border-bottom:
dotted 1px #333; border-right:dotted 1px #333;">Contempary Hugo Boss
Suit</td>
<input type="hidden" name="itemdesc" value="Contempary Hugo Boss
Suit" />
<input type="hidden" name="sku" value="100" />
<input type="hidden" name="pic" value="suit.jpg" />
<td style="width: 10%; text-align: center; border-bottom: dotted
1px #333; border-right:dotted 1px #333;">
<select name="size">
<option value="S">Small</option>
<option value="M">Medium</option>
<option value="L">Large</option>
</select>
</td>
<td style="width: 10%; text-align: center; border-bottom:
dotted 1px #333; border-right:dotted 1px #333;">£500.00</td>
<input type="hidden" name="price" value="500.00" />
<td style="width: 10%; text-align: center; border-bottom: dotted
1px #333; border-right:dotted 1px #333;">
<select name="qty">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</td>
<td style="width: 20%; text-align: center; border-bottom: dotted
1px #333; border-right:dotted 1px #333;">
<input type="submit" name="submit" value="Add to Basket" />
</td>
</tr>
</form>
<form action="addtocart.php" method="post" name="addtocart">
<tr class="datarow">
<td style="width: 20%; text-align: center; border-left:dotted
1px #333; border-bottom: dotted 1px #333; border-right:dotted 1px #333;">
<img src="img/suit1.jpg" width="112px" />
</td>
<td style="width: 30%; text-align: center; border-bottom:
dotted 1px #333; border-right:dotted 1px #333;">Wool Hugo Boss Suit</td>
<input type="hidden" name="itemdesc" value="Wool Hugo Boss Suit"
/>
<input type="hidden" name="sku" value="101" />
<input type="hidden" name="pic" value="suit1.jpg" />
<td style="width: 10%; text-align: center; border-bottom: dotted
1px #333; border-right:dotted 1px #333;">
<select name="size">
<option value="S">Small</option>
<option value="M">Medium</option>
<option value="L">Large</option>
</select>
</td>
<td style="width: 10%; text-align: center; border-bottom:
dotted 1px #333; border-right:dotted 1px #333;">£450.00</td>
<input type="hidden" name="price" value="450.00" />
<td style="width: 10%; text-align: center; border-bottom: dotted
1px #333; border-right:dotted 1px #333;">
<select name="qty">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</td>
<td style="width: 20%; text-align: center; border-bottom: dotted
1px #333; border-right:dotted 1px #333;">
<input type="submit" name="submit" value="Add to Basket" />
</td>
</tr>
</form>
</table>
</div>
</div>
<?php
include('footer.php');
?>
</body>
</html>
A file called ._mens.php Is NOT the same as a file called mens.php
As you are using the url localhost/example/mens.php then the file needs to be called mens.php

Valid Regex Not so valid in PHP [duplicate]

This question already has answers here:
Warning: preg_replace(): Unknown modifier
(3 answers)
Closed 5 years ago.
So i want to extract everything in between form tags (including the tags them selves).
The form is as below:
<body><br />
<!--
<form method="POST" action="#">
<table style="table-layout: fixed; border: 1px solid #ffffff; " border="1">
<!--
<col width="50"> --></p>
<tr style="width: 1154px; background-color: #0d56c2; vertical-align: middle; color: #ffffff; height: 70px; ">
<td style="width: 413px; text-align: center;">Calls</td>
<td style="background-color: #D6DCE5; width: 319px; padding-left: 20px; padding-top: 15px;"><input type="text" name="calls" value="150" style="width: 173px;"></td>
<td style="width: 412px; padding: 5px; vertical-align: middle;"> in a period of <input name="period" value="5" style="width: 173px; "> <br />
<select name="callUnit" style="width: 100px; height: 29px; position: absolute;"><option value="hour" selected>hours</option><option value="minute" >minutes</option></select>
</td>
</tr>
</table>
</form>
</body>
Regex i am using is: <form.*>[\s\S]*<\/form> and according to regex101 This is a valid regular expression that should extract form tags + everthing in between.
However using the above regular expression in preg_match i get the following error: Warning: preg_match(): Unknown modifier '['
Not sure what you actual issue is. For me your pattern works like charm:
<?php
$markup = <<<HTML
<body><br />
<!--
<form method="POST" action="#">
<table style="table-layout: fixed; border: 1px solid #ffffff; " border="1">
<!--
<col width="50"> --></p>
<tr style="width: 1154px; background-color: #0d56c2; vertical-align: middle; color: #ffffff; height: 70px; ">
<td style="width: 413px; text-align: center;">Calls</td>
<td style="background-color: #D6DCE5; width: 319px; padding-left: 20px; padding-top: 15px;"><input type="text" name="calls" value="150" style="width: 173px;"></td>
<td style="width: 412px; padding: 5px; vertical-align: middle;"> in a period of <input name="period" value="5" style="width: 173px; "> <br />
<select name="callUnit" style="width: 100px; height: 29px; position: absolute;"><option value="hour" selected>hours</option><option value="minute" >minutes</option></select>
</td>
</tr>
</table>
</form>
</body>
HTML;
preg_match('~<form.*>([\s\S]*)</form>~', $markup, $tokens);
var_dump($tokens[1]);
The output of that is:
string(829) "
<table style="table-layout: fixed; border: 1px solid #ffffff; " border="1">
<!--
<col width="50"> --></p>
<tr style="width: 1154px; background-color: #0d56c2; vertical-align: middle; color: #ffffff; height: 70px; ">
<td style="width: 413px; text-align: center;">Calls</td>
<td style="background-color: #D6DCE5; width: 319px; padding-left: 20px; padding-top: 15px;"><input type="text" name="calls" value="150" style="width: 173px;"></td>
<td style="width: 412px; padding: 5px; vertical-align: middle;"> in a period of <input name="period" value="5" style="width: 173px; "> <br />
<select name="callUnit" style="width: 100px; height: 29px; position: absolute;"><option value="hour" selected>hours</option><option value="minute" >minutes</option></select>
</td>
</tr>
</table>
"
The only modification I made is to add the capture group ((...)) to be able to actually extract something.
You are escaping the forward slash in the closing </form> tag with a back slash. Most likely that is because online regex tools like regex101 use forward slashes as standard delimiters in their patterns. Note that you can use other characters which makes the pattern easier to read, since you do not have to escape characters then...
I suspect that you maybe forgot to place your pattern in between delimiters?

MySql/PHP - How can I insert data into 2 different tables at the same time (using Array)

I have a form that creates request. By clicking on the 'Create Request' button all the information is added to the 'Requests_Table'. This is working perfectly. Each request has more than one item (at least one)... and each item is comprised of its own characteristics (that's why I want to store this info on a separate table 'SerialNumber_Table'.
So, I need help inserting the Serial number information (Type,Model,Serial number) into 'SerialNumber_Table'. I believe I'll also need to use mysql_insert_id(); to associate each serial number with the correct request_id.
`
//Variables for Serial Numbers
$machineType = mysql_prep($_POST['machineType']);
$machineModel = mysql_prep($_POST['machineModel']);
$serialNumber = mysql_prep($_POST['serialNumber']);
<fieldset class="row2">
<h1><?php echo $LANG['hardware_details']; ?></h1>
<p style="margin: 10px 0 10px 0; ">
<p style="margin: 10px 0 10px 0; font-size:12px; padding: 0;"><?php echo $LANG['delete_machines']; ?></p>
<input type="button" value="<?php echo $LANG['add_machines']; ?>" onClick="addRow('dataTable')" style="width: 100px; padding: 2px 5px 2px 5px; background: #e1e1e1; color: #000; font-weight: bold; font-size: 12px; cursor: pointer;" />
<input type="button" value="<?php echo $LANG['remove_machines']; ?>" onClick="deleteRow('dataTable')" style="width: 130px; margin-left: 10px; padding: 2px 5px 2px 5px; background: #e1e1e1; color: #000; font-weight: bold; font-size: 12px; cursor: pointer;" />
</p>
<table id="dataTable" class="form" border="1">
<tbody>
<tr>
<td><input type="checkbox" style=" width: 30px; "/></td>
<td>
<label style="margin-left: 10px;"><?php echo $LANG['machineType']; ?></label>
<input type="text" value="" id="machineType" name="machineType[]" style="width: 70px; margin: 5px 10px 10px 10px; ">
</td>
<td>
<label for="" style="margin-left: 10px;"><?php echo $LANG['machineModel']; ?></label>
<input type="text" value="" id="machineModel" name="machineModel[]" style="width: 70px; margin: 5px 10px 10px 10px;">
</td>
<td>
<label for="" style="margin-left: 10px;"><?php echo $LANG['serialNumbers']; ?></label>
<input type="text" value="" id="serialNumber" name="serialNumber[]" style="width: 120px; margin: 5px 10px 10px 10px;">
</td>
</tr>
</tbody>
</table>
<div class="clear"></div>
</fieldset>
<!-- End Dynamic Forms for Serial Numbers -->
`
How could I achieve such a task?
If it is any help, I have posted the entire code for this page at http://aerco.com.br/stackoverflow/source.txt
Anyone can point me in the right direction here?
Thanks in advance for any thoughts
I could not get what is yout exact need, but for my understanding, You can insert into one table using code and another using MySQL trigger.
Explained over here: http://dev.mysql.com/doc/refman/5.0/en/triggers.html
would the user be the one to supply the serial or is it predefined? this should be the code you need for inserting
$query = "INSERT INTO serialnumber_table(Type,Model,Serial number,request_id) VALUES ($machineType, $machineModel,$serial_number,request_id)
request_id should be gotten from requests table.
if my understanding is correct, insert after this code
$query = "INSERT INTO requests(
request_date, requester_name, requester_email, client_name, client_country, opportunity_number, machine_quantity, severity, specialist, created_by, sales_connect
) VALUES (
'{$request_date}', '{$requester_name}', '{$requester_email}', '{$client_name}', '{$client_country}', '{$opportunity_number}', '{$machine_quantity}', '{$severity}', '{$specialist}', '{$created_by}', '{$sales_connect}'
)";

How to POST dynamic input tags in codeigniter

I am facing a serious dilemma, and wondering how this would be possible. I have a form built in codeigniter framework. At the end of the form is an input tag which takes a number and appends a new form with exact rows of input tags as the value of the last input tag. I have done this using javascript, code is
$('#formName9').on('change', function() {
var selected = $(this).val();
$('#subForm').empty();
$("#subForm").append('<table border="" style="border:none; background:#f2f2f1; margin-bottom:10px; border-collapse: collapse; margin-top: 25px; box-shadow: 9px 4px 8px rgba(50, 50, 50, 0.75);" cellspacing="0" cellpadding="0"> <tr> <td style="text-align: center; width: 30px; border-width: 0px;"><img src="<?php echo base_url(); ?>assets/img/icon_house.png" ></td> <td style="text-align: center; border-width: 0px;"><img src="<?php echo base_url(); ?>assets/img/table_divider.png" /></td> <td style="text-align: center; width: 200px; border-width: 0px;"><strong>Unit Name</strong></td> <td style="text-align: center; border-width: 0px;"><img src="<?php echo base_url(); ?>assets/img/table_divider.png" /></td> <td style="text-align: center; width: 250px; border-width: 0px;" ><strong>Owner Name</strong></td> <td style="text-align: center; border-width: 0px;"><img src="<?php echo base_url(); ?>assets/img/table_divider.png" /></td> <td style="text-align: center;width: 150px; border-width: 0px;"><strong>Owner Salutation</strong></td> </tr> </table>');
for (var i=1; i<=selected; i++) {
$('#subForm').append('<div style="float: left; padding-left: 13px; padding-right: 12px; padding-top: 7px; margin-top: 0px;">'+i+'</div><input type="text" name="unitName" id="unitName'+i+'" style="width:189px;" required /><input type="text" name="ownerName'+i+'" id="ownerName'+i+'" style="width:241px;" /><input type="text" name="salutation'+i+'" id="salutation'+i+'" style="width:137px;" /><br />');
}
});
you can see i have used different naming conventions for all the appended tags according to the loop.
Now these values need to be posted in order for the PHP[SERVER] to do further work, but how will i post these dynamic values? i have tried to the following, but this just hangs my local server and doesn't go any further
$ownerName = array();
for ($i=0; $i<=$blockUnits ; $i+1) {
$ownerName[$i] = "ownerName".$i;
$this->input->post('ownerName[$i]');
}
While adding new input text boxes, give names for those fields as given below.
For example if user wants to add 5 fields, then the output will become something like
<input type="text" name="ownerName[]" />
<input type="text" name="ownerName[]" />
<input type="text" name="ownerName[]" />
<input type="text" name="ownerName[]" />
<input type="text" name="ownerName[]" />
Then in PHP you can get values of these fields like
$ownerNames = $_POST['ownerName'];
foreach( $ownerNames as $ownerName ) {
echo "Owner Name is : " . $ownerName;
}
As you are trying in CodeIgniter, the code will look something like this (getting post variable)
$ownerNames = $this->input->post('ownerName');
foreach( $ownerNames as $ownerName ) {
echo "Owner Name is : " . $ownerName;
}
i think it should be easier if you post your value in array ...
example..
<input type="text" name="ownerName[]" id="ownerName'+i+'" style="width:241px;" />
and loop it in controller...
foreach($this->input->post('ownerName') as test){
.....
}
similar for others

updating filtered mysql rows in php

I'm trying to update different rows from mysql that they filtered by some record . in this code first the user should enter two input : classnumber and level .
records that they have this fields will show in table then the user should be able to update this records information . but the problem is all of records are in one table in mysql so their id is different I mean for example the first record that match with two inputs id is 2 and then the next one is 5 and next one 6 and ....
with this kind of situation how should I change the code below ?
<form id="searchform" method="post" dir="rtl" action="">
level :<input name="level" style="margin-top:5px; margin-left:6px;font-family: Tahoma,Geneva,sans-serif; font-size: 12px; margin-top: 5px; padding: 5px; width: 50px;" type="text" id="level" />
classnumber :<input name="classnum" style="margin-top:5px; margin-left:6px;font-family: Tahoma,Geneva,sans-serif; font-size: 12px; margin-top: 5px; padding: 5px; width: 50px;" type="text" id="classnum" />
<input style="margin-top:10px; margin-left:120px; font-size: 14px; padding: 5px 14px;" type="submit" value="جستجو" name="enter" />
</form>
<?php
if(isset($_POST['enter'])){
$sql="SELECT * FROM `".$tbl_name."` where classnum='".$_REQUEST['classnum']."' and level='".$_REQUEST['level']."' ";
$result=mysql_query($sql,$link);
$count=mysql_num_rows($result);
}
?>
<div class="cleaner h30"></div>
<br>
<form name="form1" action="" method="POST">
<center>
<div>
<div align="center" width = 615>
<table class="stats" cellspacing="0" width="615" border="1">
<tr>
<th width="20" scope="col" >Id</th>
<th width="60" scope="col">Name</th>
<th width="60" scope="col">Last Name</th>
<th width="42" scope="col">Midterm</th>
<th width="54" scope="col">Class mark</th>
<th width="42" scope="col">Final Quiz</th>
<th width="54" scope="col">State</th>
<th width="54" scope="col">Details</th>
</tr>
<?php
while($rows=mysql_fetch_array($result)){
$id[]=$rows['id'];
?>
<tr>
<td align="center">
<input name="id[]" type="text" id="id" value="<? echo $rows['id']; ?>" style=" font-family: Tahoma,Geneva,sans-serif; font-size: 12px; padding: 5px; width: 10px;"></td>
<td align="center"><input style=" font-family: Tahoma,Geneva,sans-serif; font-size: 12px; padding: 5px; width: 60px;" type="text" name="name[]" id="name" value= "<? echo $rows['name']; ?>" /></td>
<td align="center"><input style=" font-family: Tahoma,Geneva,sans-serif; font-size: 12px; padding: 5px; width: 60px;" type="text" name="lastname[]" id="lastname" value= "<? echo $rows['lastname']; ?>" /></td>
<td align="center"><input style=" font-family: Tahoma,Geneva,sans-serif; font-size: 12px; padding: 5px; width: 50px;" type="text" name="midmark[]" id="midmark" /></td>
<td align="center"><input style=" font-family: Tahoma,Geneva,sans-serif; font-size: 12px; padding: 5px; width: 50px;" type="text" name="classmark[]" id="classmark" /></td>
<td align="center"><input style=" font-family: Tahoma,Geneva,sans-serif; font-size: 12px; padding: 5px; width: 50px;" type="text" name="finalmark[]" id="finalmark" /></td>
<td align="center"><input style=" font-family: Tahoma,Geneva,sans-serif; font-size: 12px; padding: 5px; width: 50px;" type="text" name="state[]" id="state" /></td>
<td align="center"><input style=" font-family: Tahoma,Geneva,sans-serif; font-size: 12px; padding: 5px; width: 50px;" type="text" name="details[]" id="details" /></td>
</tr>
<?php
}
?>
</table>
</div>
</div>
</center>
<input style="margin-top:10px; float:right; margin-right:175px; font-size: 14px; padding: 5px 14px;" type="submit" value="ثبت" name="Submit" />
</form>
<?php
// Check if button name "Submit" is active, do this
if(isset($_POST['Submit']))
{
for($i=0;$i<$count;$i++)
{
$sql1=mysql_query(" UPDATE `".$tbl_name."` SET midmark='".$_REQUEST['midmark'][$i]."' , classmark='".$_REQUEST['classmark'][$i]."' , finalmark='".$_REQUEST['finalmark'][$i]."' , state='".$_REQUEST['state'][$i]."' , details='".$_REQUEST['details'][$i]."' WHERE id='".$_REQUEST['id'][$i]."' "); $result1=mysql_query($sql1);
}
}
if($result1){
header("location:results.php");
}
mysql_close();
?>

Categories