See I'm having this problem when i pass an argument from my database to a javascript function i get a number that decrements and also it's a different number from what i expect to show up
the format of what im passing is (####-####)
<?php
include 'connect.php';
session_start();
if(isset($_SESSION['name']) && $_SESSION['name'] != "")
{
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="css/main.css" />
<script src="js/main.js"></script>
</head>
<body>
<div id="TopContainer">
<div id="user">
<div id="msg">
<a href="logout.php">
<button type="button" style="width:60px;float:right;padding:5px;" class="submit">
Log Out
</button>
</a>
<span style="float:left;">
Hello, <?php echo $_SESSION['name']; ?>
</span>
</div>
</div>
<form action="main.php" method="POST" id="form" name="form">
<div id="box" name="box" style="-webkit-transition:1s;overflow:hidden;">
<label class="boxes"><input type="checkbox" id="All" name="All" onclick="checkAll()" /><span>All</span></label>
<label class="boxes"><input type="checkbox" id="books" name="books" onclick="rmOthers(1)"/><span>Books</span></label>
<label class="boxes"><input type="checkbox" id="journals" name="journals" onclick="rmOthers(2)"/><span>Journals</span></label>
<label class="boxes"><input type="checkbox" id="guidelines" name="guidelines" onclick="rmOthers(3)"/><span>Guidelines</span></label>
<label class="boxes"><input type="checkbox" id="pe" name="pe" onclick="rmOthers(4)"/><span>Patient Education</span></label>
</div>
<button type="button" class="submit" id="hide" style="padding:15px 20px;" onclick="hideBoxes()">+</button><input type="search" name="search" class="inputs" placeholder="Search Articles" value="<?php echo isset($_POST['search']) ? $_POST['search'] : ""; ?>" /><button type="submit" name="submit" class="submit" >Search</button><br />
<div id="sq">
<select id="sqType" style="width:5%;">
<option class="ar">And</option>
<option class="ar">Or</option>
</select>
<input type="search" class="inputs" placeholder="Filter Results" name="filter" style="width:70%;" value='<?php echo (isset($_POST['filter']) ? $_POST['filter'] : ''); ?>' />
<button type='submit' id="fil" name='btn_filter' class="submit" style="-webkit-transform:translateX(-5px) translateY(-3px); width:7%;" >Filter</button>
</div>
</form>
</div>
<br /><br /><br /><br /><br /><br /><br /><br />
<div id="BottomContainer">
<?php
if((isset($_POST['submit'])) || (isset($_POST['btn_filter'])))
{
$search = mysqli_real_escape_string($con,$_POST['search']);
$sql = (strcmp($search, "") == true ? "SELECT * FROM tbl_additionals JOIN tbl_general_info WHERE tbl_general_info.reference_number LIKE '%$search%' OR tbl_general_info.title LIKE '%$search%' OR tbl_general_info.author LIKE '%$search%' OR tbl_additionals.abstract LIKE '%$search%'" : "SELECT * FROM tbl_additionals JOIN tbl_general_info WHERE tbl_general_info.reference_number LIKE '%$search%' OR tbl_general_info.title LIKE '%$search%' OR tbl_general_info.author LIKE '%$search%' OR tbl_additionals.abstract LIKE '%$search%' LIMIT 30");
$query = mysqli_query($con, $sql);
if(mysqli_num_rows($query) != 0)
{
while($run = mysqli_fetch_assoc($query))
{
$reference = (string)$run['reference_number'];
$title = (strlen($run['title']) > 121) ? substr($run['title'], 0, strpos(wordwrap($run['title'], 121), "\n")) . '...' : $run['title'];
echo '<div class="SearchResults">';
echo " <span class='top'>";
echo " <a>";
echo " <h3>". strtoupper($title) ."</h3>";
echo " </a>";
echo " <br />";
echo " <h5 class='sub'>";
echo $run['reference_number'];
echo " Authors :<a class='authors'>Dr.Michael Ramsay</a><a class='authors'>Dr.Lars Benitez</a><a class='authors'>Dr.Kevin John Pascual</a><br><br>";
echo " </h5>";
echo " </span>";
echo " <span class='bottom'>";
echo " <span class='bottomLeft'>";
echo ($run['abstract'] != "" ? " <a class='options' onclick='showOverlay(".$reference.")'>Abstract</a><span style='margin:0px 5px;'>|</span>" : "" );
echo " <a target='_blank' href='view.php?filename=NKTI Proceedings vol. 1 no. 1 Feb. 1996' class='options'>";
echo " Full Article";
echo " </a>";
echo " </span>";
echo " <div class='overlay' id='". $run['reference_number'] ."' onclick='hideOverlay(this, event)'> ";
echo " <iframe class='abstract' src='abstract.php?id=".$run['reference_number']."' style='padding:0px;' scrolling='no'>";
echo " </iframe>";
echo " </div>";
echo " <span class='bottomRight'>";
echo " <p class='label'>NKTI Proceedings volume 1, January - April 2015 # Pg. 1-15</p>";
echo " </span>";
echo " </span>";
echo " <br style='clear:both;'/>";
echo "</div>";
}
}
}
?>
</div>
</body>
</html>
<?php
}
else
{
echo "<script>alert('Please Login To Continue');window.open('index.php','_self');</script>";
}
?>
here's my javascript code
function showOverlay(id)
{
alert(id);
document.getElementById(id).style['display'] = "block";
document.getElementById(id).style['opacity'] = "1";
}
i just made that alert statement just so i can see what the program is passing on javascript here's what happens
i clicked on the first abstract link that showed up as you can see i echoed out that should be passed before the authors then what is passed is on the alert box
i cant seem to find what's wrong here is it my mysql statement or the javascript code or the php code
Add the ID to the Abstract link and change showOverlay(".$reference.") to onclick='showOverlay(this.dataset.articlenum)' See the line in PHP below:
PHP
echo ($run['abstract'] != "" ? "<a class='options' data-articlenum='" . $reference . "' onclick='showOverlay(this.dataset.articlenum)'>Abstract</a><span style='margin:0px 5px;'>|</span>" : "" );
Fiddle: http://jsfiddle.net/codyogden/0eea7gxw/
Related
I have a database which consists of question_id, question, and options. Where I'll display the question and options. When the user clicked on submit I want to store the option they clicked and the question_id.
I am able to store the option they clicked but want to know how to store the question_id.
$user_email = $_SESSION['email'];
$query1="SELECT * FROM votes WHERE user_email='$user_email'";
$query2="SELECT * FROM poll_question WHERE status='1'";
$fetch2 = mysqli_query($con,$query2);
<html>
<head>
<body>
<div class="container">
<br />
<br />
<br />
<div class="row">
<div class="col-md-6">
<?
while( $row2 = mysqli_fetch_array($fetch2))
{
?>
<form method="post" class="poll_form">
<h3><?echo $row2['question']?>?</h3>
<br />
<div class="radio">
<label><h4><input type="radio" name="poll_option" class="poll_option" value=<?echo $row2['option1']?> /><?echo $row2['option1']?></h4></label>
</div>
<div class="radio">
<label><h4><input type="radio" name="poll_option" class="poll_option" value=<?echo $row2['option1']?> /> <?echo $row2['option2']?></h4></label>
</div>
<br />
<?php
if( $count >0)
{ ?>
<button disabled="disabled" alt="<?php echo $row2['question_id']; ?>" rel="<?php echo $user_email; ?>" class="btn btn-primary poll_option" title="<?php echo $ip; ?>">Submit</button>
<h>You selected : <? echo $row1['vote_option']; ?></h>
<br>
<p id="demo"></p>
<?php
}
else
{ ?>
<button alt="<?php echo $row2['question_id']; ?>" rel="<?php echo $user_email; ?>" class="btn btn-primary poll_option" title="<?php echo $ip; ?>">Submit</button>
<?
}
?>
</form>
<? }
} ?>
<br />
</div>
</div>
<br />
<br />
<br />
</div>
</body>
<script type="text/javascript">
$(document).ready(function(){
$(".poll_form").submit(function(event){
event.preventDefault(); //prevents the form from submitting normally
var poll_option = '';
$('button.poll_option').each(function(){
if($(this).prop("checked"))
{
poll_option = $(this).val();
var option=poll_option;
}
var url = '<?php echo SITE_URL; ?>';
});
$.post("poll_vote.php",$('.poll_form').serialize(),
function(data)
{
if(data=="User Created Success"){
window.setTimeout(function () {
location.href ="<?php echo SITE_URL; ?>poll.php";
}, 100);
}
else{
$("#result").html(data);
}
}
);
//to reset form data
});
});
<? } ?>
</script>
</html>
Using th below function I am sending the poll_option to other where I kept the inset operation. Now I want to send the question_id also
Create a hidden input filed in your form
<input type="hidden" name="question_id" value="<?php echo $row2['question_id']; ?>">
Create a hidden input field in your form.
<input type="hidden" id="question_id" name="question_id" value="<?= $row2['question_id'] ?>">
PHP solution:
In this case your question_id will be included in the POST.
You can then access it by calling $_POST['question_id'].
Jquery solution:
In Jquery you can also access it by:
$("#question_id").val();
i have a php while loop in which there are multiple outputs of posts in whcih people can comment now i want to hide the posts comments on which submit button is clicked
this is my code
<form method="POST" action="" >
<div class="commentdiv">
<input type="hidden" name="id" id="id" class="id" value="<?php echo $pixid;?>">
<input type="hidden" name="username" id="username" value="<?php echo $activeusername;?>">
<input type="hidden" name="uid" id="uid" value="<?php echo $id3;?>">
<textarea style="" name="comment" id="comment" class="comment" placeholder=" comment here"></textarea>
<button type="button" style="background-color: Transparent;
background-repeat:no-repeat;
border: none;
cursor:pointer;
overflow: hidden;
color: #3897f0; font-weight:600;" class="submit" id="button_id">comment</button>
</div>
</form>
<div id="comments" class="comments">
<?php
$sql = "SELECT * FROM comment where post_id='$pixid' order by time2 desc limit 3";
$results = mysqli_query($con,$sql);
if (mysqli_num_rows($results)>0) {
while ($row = mysqli_fetch_assoc($results)) {
$commentid = $row['id'];
$comment = $row['comment'];
$string = covertHashtags($comment);
echo "<p class='written'>";
echo "<a href='users2?id=".$row['user_id']."' style='color:black !important;'><b>".$row['username']."</b></a>";
echo " ".$string;
$sql3 = "SELECT * FROM comment where id ='$commentid' and user_id='$id' order by comment desc limit 5 ";
$results3 = mysqli_query($con,$sql3);
if (mysqli_num_rows($results3)>0) {
echo "<div class='dropdown'>
<img src='ellipsis.png' class='dots'>
<div class='dropdown-content'>
<br><p class='delete' data-delete=".$commentid.">delete</p>
</div>
</div>";
}
else{
echo "";
}
echo "</p>";
}
}else{
echo "";
}
?>
</div>
</div>
<br><br>
<?php } ?>
this is all in a while loop so all output have same classes now if i click on submit button of first post so i want the comment section of that post to dissapear not of all the posts only that particular posts's comment div
ive tried
$(this).closest('.comments').next('.comments');
and
$(this).closest('.comments');
$(this).next('.comments');
but no luck nothing is happening in return plzz help me
The comments are in a div next to the form which contains the button.
So on click of that button, it would be:
$(this).closest("form").next(".comments").hide();
i want to insert picture in particular name but there is no insert and some facing error
my table like this
how can insert pic in front of particular name
config.php file is
<?php
session_start();
$db = new mysqli('localhost','root','','dharmesh');
?>
and code is here :
<?php
include_once('config.php');
if(isset($_POST['family_member_btn'])) {
$family_member = $_POST['family_member'];
}
if(isset($_POST["submit4"])) {
for($i=0;$i<$_POST['num'];$i++) {
$insert = $db->query("INSERT into `multiple_insert` (`f_name`,`m_name`,`l_name`,`birth_date`) values ('".$_POST['f_name'][$i]."','".$_POST['m_name'][$i]."','".$_POST['l_name'][$i]."','".$_POST['b_date'][$i]."')");
if($insert) {
echo "<script>alert('insert successfully');</script>";
} else {
echo "<script>alert('!!!insert unsuccessfully');</script>";
}
}
}
if(isset($_POST["upload"])) {
for($i=0; $i<$_POST['img'];$i++) {
$imag = $_FILES['f_name_pic']['name'][$i];
$tmp = $_FILES['f_name_pic']['tmp_name'][$i];
$dir = "images/".$imag;
move_uploaded_file($tmp,$dir);
$query = $db->query("UPDATE `multiple_insert` SET `picture`='$dir' WHERE f_name='".$_POST['f_name'][$i]."' where user_id='1'");
}
}
?>
<html>
<head>
<title>
</title>
</head>
<body>
<form method="post" action="">
<?php
$select = $db->query("SELECT * from multiple_insert where user_id='1'");
while($select_f_name = $select->fetch_assoc()){
echo "<input type='hidden' value='1' name='img' />";
echo "<p style='background-color:red;color:yellow;width:5%;'>".$select_f_name['f_name']."</p>";
echo "<span><input type='file' name='f_name_pic[]' /></span><br><br>";
}
echo "<button name='upload'>Uplaod</button><br><br>";
?>
<label><font size="2">HOW MANY MEMBER IN YOUR FAMILY ?</font></label><br><br>
<input type="text" name="family_member" class="form-control" />
<button type="submit" name="family_member_btn" class="btn btn-lg btn-info" /><span>SUBMIT</span></button><br><br>
<?php
for($i=1;$i<=$family_member;$i++) {
?>
<input type="hidden" value="<?php echo $family_member;?>" name="num" />
<label><b><?php echo "RECORED # ".$i;?></b></label><br>
<label><font size="2">First Name</font></label>
<input type="text" name="f_name[]" class="form-control" /><br>
<label><font size="2">Middle Name</font></label>
<input type="text" name="m_name[]" class="form-control" ><br>
<label><font size="2">Last name</font></label>
<input type="text" name="l_name[]" class="form-control" /><br>
<label><font size="2">birthdate</font></label>
<input id="datepicker3" class="form-control" name="b_date[]" type="text" />
<hr style="border:solid 2px rgba(0,0,0,0.2);">
<?php } ?>
<button class="btn btn-info btn-cons from-left pull-right" type="submit" name="submit4">
<span>SUBMIT</span>
</button>
</form>
</body>
</html>
how can i done this please send me updated code for this...
You cannot do that! The interface you are looking at, is phpMyAdmin---unless you are willing to hack the core code (HIGHLY NOT RECOMMENDED TO MODIFY CORE CODE OF ANY PROJECT!).
I am performing a Form Validation in PHP. My purpose is to show the error message at the same page with form, in order to be clear for the user.
But I have to problems. First how to hide my form, where are no errors in submitting it(I want to print onl one message in this case and to hide the frm). I am trying to use:
if(false === $error)
{
//Validimi perfundoi me sukses!
echo "<script>
document.getElementById('wrap').style.display = 'none';
</script>";
echo $name;
}
but it does not function.
Second I am having problems with checkbox validation. I am using the array $activity, to save values from checkbox, as they may be multiple values, but when the user select no value at all at the checkbox part, it gives me the error that: Warning: in_array() expects parameter 2 to be array, null given even i have initialized $activity as an arra: $activity=array();.
<?php
$name_error='';
$device_error ='';
$OS_error='';
$activity_error='';
$device='';
$OS='';
$activity=array();
if(!empty($_POST['submitted']))
{//nese form eshte submitted atehere validohen fushat
$name = trim($_POST['name']);//heq hapesirat
$error = false;
if(empty($name))
{
$name_error='Emri eshte bosh. Ju lutem plotesoni emrin.';
$error=true;
}
if(empty($_POST['device']))
{
$device_error = "Ju lutem selektoni nje pajisje";
$error=true;
}
else
{
$device = $_POST['device'];
}
if(empty($_POST['OS']))
{
$OS_error ="Ju lutem selektoni sistemin operativ";
$error=true;
}
else
{
$OS = $_POST['OS'];
}
if(empty($_POST['activity']) || count($_POST['activity']) < 2)
{
$activity_error = "Ju lutem selektoni te pakten 2 aktivitete";
$error=true;
}
$activity = $_POST['activity'];
if(false === $error)
{
//Validimi perfundoi me sukses!
echo "<script>
document.getElementById('wrap').style.display = 'none';
</script>";
echo $name;
}
}
?>
<!DOCTYPE html>
<html >
<head>
<title>Computer Form</title>
<link href="compForm.css" rel="stylesheet" type="text/css" />
</head>
<body >
<div id="wrap" style="display: block">
<form method="post" action='?' id="compform" >
<div>
<div class="cont_order">
<fieldset>
<legend>Beni zgjedhjen tuaj!</legend>
<div class='field_container'>
<label >Zgjidhni pajisjen qe perdorni me shpesh:</label>
<span class="error"><?php echo $device_error;?></span>
<label class='radiolabel'><input type="radio" name="device" value="Desktop"
<?php echo ($device=='Desktop')? 'checked':''; ?>/>Desktop</label><br/>
<label class='radiolabel'><input type="radio" name="device" value="Laptop"
<?php echo ($device=='Laptop')? 'checked':''; ?> />Laptop</label><br/>
<label class='radiolabel'><input type="radio" name="device" value="Tablet"
<?php echo ($device=='Tablet')? 'checked':''; ?> />Tablet</label><br/>
</div>
<div class='field_container'>
<label for="OS">Zgjidhni Sistemin e Operimit qe perdorni:</label >
<span class='error'><?php echo $OS_error?></span>
<select id="OS" name='OS' >
<option value="">Zgjidhni OS</option>
<option <?php echo $OS=='Windows'?'selected':''; ?> >Windows</option>
<option <?php echo $OS=='Linux'?'selected':''; ?> >Linux</option>
<option <?php echo $OS=='Mac'?'selected':''; ?> >Mac</option>
</select>
</div>
<div class='field_container'>
<label >Selektoni dy aktivitetet qe preferoni me shume:</label>
<span class='error'><?php echo $activity_error ?></span>
<label><input type="checkbox" value="Programim Desktop" name='activity[]'
<?php echo (in_array('Programim Desktop',$activity)) ?'checked':'' ?> />Programim Desktop</label>
<label><input type="checkbox" value="Programim Web" name='activity[]'
<?php echo (in_array('Programim Web',$activity)) ?'checked':'' ?> />Programim Web</label>
<label><input type="checkbox" value="Dizenjim" name='activity[]'
<?php echo (in_array('Dizenjim',$activity)) ?'checked':'' ?> />Dizenjim</label>
<label><input type="checkbox" value="Analize te dhenash" name='activity[]'
<?php echo (in_array('Analize te dhenash',$activity)) ?'checked':'' ?> />Analize te dhenash</label>
<label><input type="checkbox" value="Kerkim shkencor" name='activity[]'
<?php echo (in_array('Kerkim shkencor',$activity))?> />Kerkim shkencor</label>
</div>
</fieldset>
</div>
<div class="cont_details">
<fieldset>
<legend>Detajet e kontaktit</legend>
<label for='name'>Emri</label>
<input type="text" id="name" name='name'
value='<?php echo htmlentities($name) ?>' />
<span class='error'><?php echo $name_error ?></span>
<br/>
<label for='address'>Adresa e emailit</label>
<input type="email" id="address" name='address' />
<br/>
</fieldset>
</div>
<input type='submit' name='submitted' id='submit' value='Submit' />
</div>
</form>
</div>
</body>
</html>
Here's my quick solution (untested). Let's clean up your code a little:
Instead of using (and wasting) separate variables for each error message, let's use an associative array called $errors. The keys will be the name of the inputs and the values will be their respective error messages.
To ensure that you don't get warnings from undeclared variables, we will declare variables for each input at the top of the page.
Let's also use a new variable $submitted to know whether the form was submitted or not.
Now, if the form was $submitted and there are no (!) $errors, then we hide the form. Otherwise, we show the form and any errors if there are any.
<?php
$name = '';
$device = '';
$OS = '';
$activity = array();
$submitted = !empty($_POST['submitted']);
$errors = array();
if ($submitted) {
//nese form eshte submitted atehere validohen fushat
if (empty($_POST['name'])) {
$errors['name'] ='Emri eshte bosh. Ju lutem plotesoni emrin.';
} else {
$name = trim($_POST['name']);
}
if (empty($_POST['device'])) {
$errors['device'] = "Ju lutem selektoni nje pajisje";
} else{
$device = $_POST['device'];
}
if (empty($_POST['OS'])) {
$errors['OS'] = "Ju lutem selektoni sistemin operativ";
} else {
$OS = $_POST['OS'];
}
if (empty($_POST['activity']) || count($_POST['activity']) < 2) {
$errors['activity'] = "Ju lutem selektoni te pakten 2 aktivitete";
} else {
$activity = $_POST['activity'];
}
}
?>
<!DOCTYPE html>
<html >
<head>
<title>Computer Form</title>
<link href="compForm.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php if ($submitted && !$errors) : ?>
<?php echo $name ?>
<?php else : ?>
<div id="wrap">
<form method="post" action='?' id="compform" >
<div>
<div class="cont_order">
<fieldset>
<legend>Beni zgjedhjen tuaj!</legend>
<div class='field_container'>
<label >Zgjidhni pajisjen qe perdorni me shpesh:</label>
<span class="error"><?php echo isset($errors['device']) ? $errors['device'] : '' ?></span>
<label class='radiolabel'><input type="radio" name="device" value="Desktop"
<?php echo $device == 'Desktop' ? 'checked' : '' ?>/>Desktop</label><br/>
<label class='radiolabel'><input type="radio" name="device" value="Laptop"
<?php echo $device == 'Laptop' ? 'checked' : '' ?> />Laptop</label><br/>
<label class='radiolabel'><input type="radio" name="device" value="Tablet"
<?php echo $device == 'Tablet' ? 'checked' : '' ?> />Tablet</label><br/>
</div>
<div class='field_container'>
<label for="OS">Zgjidhni Sistemin e Operimit qe perdorni:</label >
<span class='error'><?php echo isset($errors['OS']) ? $errors['OS'] : '' ?></span>
<select id="OS" name='OS' >
<option value="">Zgjidhni OS</option>
<option <?php echo $OS == 'Windows' ? 'selected' : '' ?> >Windows</option>
<option <?php echo $OS == 'Linux' ? 'selected' : '' ?> >Linux</option>
<option <?php echo $OS == 'Mac' ? 'selected' : '' ?> >Mac</option>
</select>
</div>
<div class='field_container'>
<label >Selektoni dy aktivitetet qe preferoni me shume:</label>
<span class='error'><?php echo isset($errors['activity']) ? $errors['activity'] : '' ?></span>
<label><input type="checkbox" value="Programim Desktop" name='activity[]'
<?php echo in_array('Programim Desktop', $activity) ? 'checked' : '' ?> />Programim Desktop</label>
<label><input type="checkbox" value="Programim Web" name='activity[]'
<?php echo in_array('Programim Web', $activity) ? 'checked' : '' ?> />Programim Web</label>
<label><input type="checkbox" value="Dizenjim" name='activity[]'
<?php echo in_array('Dizenjim', $activity) ? 'checked' : '' ?> />Dizenjim</label>
<label><input type="checkbox" value="Analize te dhenash" name='activity[]'
<?php echo in_array('Analize te dhenash', $activity) ? 'checked' : '' ?> />Analize te dhenash</label>
<label><input type="checkbox" value="Kerkim shkencor" name='activity[]'
<?php echo in_array('Kerkim shkencor', $activity) ? 'checked' : '' ?> />Kerkim shkencor</label>
</div>
</fieldset>
</div>
<div class="cont_details">
<fieldset>
<legend>Detajet e kontaktit</legend>
<label for='name'>Emri</label>
<input type="text" id="name" name='name' value='<?php echo htmlentities($name) ?>' />
<span class='error'><?php echo isset($errors['name']) ? $errors['name'] : '' ?></span>
<br/>
<label for='address'>Adresa e emailit</label>
<input type="email" id="address" name='address' />
<br/>
</fieldset>
</div>
<input type='submit' name='submitted' id='submit' value='Submit' />
</div>
</form>
</div>
<?php endif ?>
</body>
</html>
You can check the $_POST['submitted'] as below pseudocode:
//form is submitted
if isset $_POST['submitted']
//process form and show error message
else
//show form
I'm having a frustrating problem with a form submit. My functions are all called (checked through log file) but request-->post('..') doesn't return anything. I would be eternally thankfull to anyone who helps solve this headache.
php file loads the template, fills the form with data. form contains a button which on click calls javascript function addAllToCartProject(). this function calls the addAll function in the initial php file where I try to get the data from the form with no success.
The code I'm working on is for an OpenCart module.
template file---> project_edit.tpl
<div id="tab-products" class="tab-content">
<form method="post" enctype="multipart/form-data" id="form2">
<div class="buttons"><div class="left">
<input type="button" value="<?php echo $button_add_products; ?>" id="pselect" class="button" />
<input type="button" value="<?php echo $button_add_all_cart; ?>" id="addallltocart" onclick="addAllToCartProject();" class="button" />
<input type="button" value="<?php echo $button_print; ?>" id="printproject" class="button" />
</div></div>
<div class="cart-info">
<table>
.
.
.
</table>
<input type="hidden" name="akey" value="<?php echo $akey; ?>" />
<input type="hidden" name="eid" value="<?php echo $eid; ?>" />
</form>
</div>
javascript function
function addAllToCartProject() {
$.ajax({
url: 'index.php?route=account/projects/addAll',
type: 'post',
data: $('#form2').serialize(),
dataType: 'json',
success: function(json) {
$('.success, .warning, .attention, .information, .error').remove();
if (json['error']) {
$('#notification').html('<div class="warning" style="display: none;">' + json['error'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>');
$('.warning').fadeIn('slow');
$('#cart-total').html(json['total']);
$('html, body').animate({ scrollTop: 0 }, 'slow');
} else {
$('#notification').html('<div class="success" style="display: none;">' + json['success'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>');
$('.success').fadeIn('slow');
$('#cart-total').html(json['total']);
$('html, body').animate({ scrollTop: 0 }, 'slow');
}
}
});
}
php file-->projects.php
.
.
.
if (isset($this->request->get['project_id'])) {
$printlink = $this->url->link('projects/projects_print', 'project_id=' . $eid . '&akey=' . $akey);
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/account/projects_edit.tpl')) {
$this->template = $this->config->get('config_template') . '/template/account/projects_edit.tpl';
} else {
$this->template = 'default/template/account/projects_edit.tpl';
}
} else { ..............}
.
.
.
public function addAll() {
$this->language->load('checkout/cart');
$this->language->load('account/projects');
$this->load->model('account/projects');
if (isset($this->request->post['eid'])) {
$eid = $this->request->post['eid'];
} else {
$eid = '0';
$file="log.txt";
$log=fopen($file,'a');
fwrite($log,"\n eid is not set ");
fclose($log);
}
if (isset($this->request->post['akey'])) {
$akey = $this->request->post['akey'];
} else {
$akey = '0';
$file="log.txt";
$log=fopen($file,'a');
fwrite($log,"\n akey is not set ");
fclose($log);
}
.
.
.
}
May be try to give names attribute to your form elements:
<div id="tab-products" class="tab-content">
<form method="post" enctype="multipart/form-data" id="form2">
<div class="buttons"><div class="left">
<input name = "products" type="button" value="<?php echo $button_add_products; ?>" id="pselect" class="button" />
<input name = "cart" type="button" value="<?php echo $button_add_all_cart; ?>" id="addallltocart" onclick="addAllToCartProject();" class="button" />
<input name = "print" type="button" value="<?php echo $button_print; ?>" id="printproject" class="button" />
</div></div>
<div class="cart-info">
<table>
.
.
.
</table>
<input type="hidden" name="akey" value="<?php echo $akey; ?>" />
<input type="hidden" name="eid" value="<?php echo $eid; ?>" />
</form>
</div>