I have made a form. Why aren't the submit (enviar) and reset (restablecer) buttons displayed? If I remove the PHP code, they do appear. Why?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Documento sin título</title>
</head>
<body>
<div>
<form action="" id="noti-form"method="post" enctype="multipart/form-data" name="noticia">
Antetítulo de la Noticia<br />
<input type="text" name="ante" size="70" id="ante" class="inputbox" />
<br />
Título de la Noticia<br />
<input type="text" name="titulo" size="70" id="titulo" class="inputbox" />
<br />
Subtítulo de la Noticia<br />
<input type="text" name="sub" size="70" id="sub" class="inputbox" />
<br />
Autor:<br />
<input type="text" name="autor" size="30" id="autor" class="inputbox" />
<br />
Texto de la Noticia<br />
<div align="center">
<textarea id="elm1" name="noticia" class=".noticia" rows="15" cols="80" style="width: 80%"></textarea></div>
<br />
<input type="file" name="foto" id="foto" />
<br />
<?php
echo '<select class="chosen" name="tags[ ]" multiple="true" style="width:400px;">';
$query=$database->tags();
foreach ($query as $data) {
echo '<option value="'.$data['tag'].'">'.$data['tag'].'</option>';
}
echo'</select>';
?>
<input type="submit" name="enviar" value="Enviar" class="button" />
<input type="reset" name="button" id="button" value="Restablecer" class="button" />
</form>
</div>
</body>
</html>
Related
I would like to know how to increase a element, each time that element is posted.
I have to use for loop for the auto increment, but i am not getting right. So any advise or guidance will be great.
Here is the way i have tried to do:
Thanks
<?php
$id=0;
if (isset($_POST['submit'])) {
$do = $_POST['prodCode'];
$di = count($do);
while ($di > $id) {
$id++;
echo $id;
}
}
?>
<!DOCTYPE HTML>
<html>
<head>
<title>Session test</title>
</head>
<body>
<div class="holder">
<div class="im">
<img src="session-test/images/bestorange-juice.jpg" />
<p>bestorange-juice</p>
<form method="post" action="sessiontest.php">
<input type="hidden" id="prodCode" name="prodCode" value="f102" />
<input type="hidden" id="prodPrice" name="prodPrice" value="25" />
<!--<input type="text" id="prodQty" name="prodQty" value="1" size="1"/>-->
<input type="submit" value="send value" name="submit" id="submit" />
</form>
</div>
<div class="im">
<img src="session-test/images/milkshake-juice.jpg" />
<p>bestorange-juice</p>
<form method="post" action="sessiontest.php">
<input type="hidden" id="prodCode" name="prodCode" value="W122" />
<input type="hidden" id="prodPrice" name="prodPrice" value="1" />
<!--<input type="text" id="prodQty" name="prodQty" value="1" size="1"/>-->
<input type="submit" value="send value" name="submit" id="submit" />
</form>
</div>
</div>
</body>
</html>
Try below code, counts are stored in session, but for real life app you should use database and also you should get your products from database:
<?php
// initialize counts for f102 and W122 products
if (!isset($_SESSION['count_f102']) {
$_SESSION['count_f102'] = 0;
}
if (!isset($_SESSION['count_W122']) {
$_SESSION['count_f102'] = 0;
}
if (isset($_POST['submit'])) {
$do = $_POST['prodCode'];
// increment count for product which was submitted
$_SESSION['count_'.$do] = 1+ (int) $_SESSION['count_'.$do];
}
?>
<!DOCTYPE HTML>
<html>
<head>
<title>Session test</title>
</head>
<body>
<div class="holder">
<div class="im">
<img src="session-test/images/bestorange-juice.jpg" />
<p>bestorange-juice</p>
<form method="post" action="sessiontest.php">
<input type="hidden" id="prodCode" name="prodCode" value="f102" />
<input type="hidden" id="prodPrice" name="prodPrice" value="25" />
<input type="text" id="prodQty" name="prodQty" value="<?php $_SESSION['count_f102'] ?>" size="1" readonly="readonly" />
<input type="submit" value="send value" name="submit" id="submit" />
</form>
</div>
<div class="im">
<img src="session-test/images/milkshake-juice.jpg" />
<p>bestorange-juice</p>
<form method="post" action="sessiontest.php">
<input type="hidden" id="prodCode" name="prodCode" value="W122" />
<input type="hidden" id="prodPrice" name="prodPrice" value="1" />
<input type="text" id="prodQty" name="prodQty" value="<?php $_SESSION['count_W122'] ?>" size="1" readonly="readonly" />
<input type="submit" value="send value" name="submit" id="submit" />
</form>
</div>
</div>
</body>
</html>
Are your $_POST['prodCode'] always in the form one letter + id ? If yes maybe this could help :
if (isset($_POST['prodCode'])) {
$value = $_POST['prodCode'];
// save the letter
$letter = substr($value, 0, 1);
// get id
$id = (int) substr($value, 1, strlen($value) - 1);
// get value with letter and incremented id
$valueIncremented = $letter . ++$id;
}
// with $_POST['prodCode'] = 'f102' you will get $valueIncremented = 'f103'
Hope it helps.
I'm totally new to php and I am trying to dynamically change the form displayed when the user makes a choice on a drop down list. I can get the drop down list to show but it does not display anything when I submit.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<title>Forms</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<?php
If (!isset($_GET['userChoice']))
{ //open the if block to write the html to the screen
?>
<h1>Show your html option form</h1>
<form method="GET" action="thirdtry.php" name="userChoice">
<select size="1" id="choice" name="choice">
<option selected="selected">Choose which form you would like</option>
<option value="feedback">Feedback Form </option>
<option value="help">Help Request Form</option>
</select>
<input type="submit">
</form>
<?php
}//close the if block
else{ //show feedback
if($_GET['userChoice']=="feedback")
{
?>
<h1>Show the feedback form</h1>
<form id="fb" name="fb" method="post" >
<fieldset>
<label>First Name:
<br />
<input type="text" name="fName" id="fName" />
</label>
<br />
<label>Last Name:
<br />
<input type="text" name="lName" id="lName" />
</label>
<br />
<label>Street Address:
<br />
<input type="text" name="address" id="address" />
</label>
<br />
<label>City
<br />
<input type="text" name="city" id="city" />
</label>
<br />
<label>State
<br />
<input type="text" name="state" id="state" />
</label>
<br />
<label>Postcode
<br />
<input type="text" name="postcode" id="postcode" />
</label>
<br />
<label>Country
<br />
<input type="text" name="country" id="country" />
</label>
<br />
<label>Email Address:
<br />
<input type="text" name="FromAddress" id="FromAddress" />
</label>
<br />
<label>Your message:
<br />
<textarea name="message" rows="7" cols="30"></textarea> <br />
</label>
<div>How many stars would you give this site? <br />
(We love 5 stars!)<br />
<input type="radio" name="rating" value="1" />1<br />
<input type="radio" name="rating" value="2" />2<br />
<input type="radio" name="rating" value="3" />3<br />
<input type="radio" name="rating" value="4" />4<br />
<input type="radio" name="rating" value="5" />5<br />
</div>
<br />
<input type="submit" />
<input type="reset" />
</fieldset>
</form>
<?php
}
else
{//must be help form
?>
<h1>Show the help form</h1>
<form id="help" method="post" >
<fieldset>
<label>First Name:
<br />
<input type="text" name="fNameHelp" id="fNameHelp" />
</label>
<br />
<label>Last Name:
<br />
<input type="text" name="lNameHelp" id="lNameHelp" />
</label>
<br />
<label>Street Address:
<br />
<input type="text" name="addressHelp" id="addressHelp" />
</label>
<br />
<label>City
<br />
<input type="text" name="cityHelp" id="cityHelp" />
</label>
<br />
<label>State
<br />
<input type="text" name="stateHelp" id="stateHelp" />
</label>
<br />
<label>Postcode
<br />
<input type="text" name="postcodeHelp" id="postcodeHelp" />
</label>
<br />
<label>Country
<br />
<input type="text" name="countryHelp" id="countryHelp" />
</label>
<br />
<label>Email Address:
<br />
<input type="text" name="FromAddress" />
</label>
<br />
<label>Your message:
<br />
<textarea name="messageHelp" rows="7" cols="30"> </textarea> <br />
</label>
<div>How Would you like to be contacted?<br />
(Choose all that apply) <br />
<input type="checkbox" name="ckemail" id="ckemail" value="email" onclick="return validateHelpForm()"/>email<br />
<input type="checkbox" name="cktelephone" id="cktelephone" value="telephone" onclick="return validateHelpForm()"/>telephone<br />
</div>
<br />
<input type="submit" />
<input type="reset" />
</fieldset>
</form>
<?php
}//close the if block
}
?>
</body>
</html>
You're checking for the wrong variable:
If (!isset($_GET['userChoice']))
should be
If (!isset($_GET['choice']))
Also, why are you capitalizing If? (That won't cause an issue - it's just weird ;)
Well first off, do you want the page to refresh, or would you like it to change dynamically without a refresh, using Javascript. From your brief description, I am thinking you want the change to happen without a refresh.
And being a "novice", I would advise you use Jquery as your Framework as opposed to full blown javascript. Here is what I think you're trying to accomplish.
Since PHP is a server-side programming language, you can't dynamically change a webpage without a refresh. Javascript and Jquery are client-side, so many things can happen in your browser without the need or a refresh.
LINK: Here is the example I just created.
////////jquery/javascript///////
$('#changeme').change(function(){
var value = $('#changeme').val();
if(value == 1){
$('#dis1').show();
$('#dis2').hide();
}
else if(value == 2){
$('#dis1').hide();
$('#dis2').show();
}
else{
$('#dis1').hide();
$('#dis2').hide();
}
});
////////HTML///////
<select id="changeme">
<option value=""></option>
<option value="1">1</option>
<option value="2">2</option>
</select>
<div style="display:none;" id="dis1">Displaying 1</div>
<div style="display:none;" id="dis2">Displaying 2</div>
I am working on oops based project in php when I upload an image it is not uploade with information that I want to upload with this image. Here i connect the controller page I create object for uploading the image and information in database.
Code for html page
<?php
include('include/control.php');
include('include/connect.php');
error_reporting(0);
if(count($_FILES) > 0){
if(is_uploaded_file($_FILES['image']['tmp_name'])){
$i=addslashes(file_get_contents($_FILES['image']['tmp_name']));
$j=getimagesize($_FILES['image']['tmp_name']);
$objectNew=new add;
if(isset($_POST['submit'])){
$info1=$_POST['info1'];
$info2=$_POST['info2'];
$info3=$_POST['info3'];
$info4=$_POST['info4'];
$info5=$_POST['info5'];
$imagetype=$i;
$imageData=$j;
$ob=$objectNew->addInfo($imagetype,$imagedata,$info1,$info2,$info3,$info4,$info5);
}
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
add info<br />
<form name="form" enctype="multipart/form-data" action="" method="post">
<input type="text" name="info1" /><br />
<input type="text" name="info2" /><br />
<input type="text" name="info3" /><br />
<input type="text" name="info4" /><br />
<input type="text" name="info5" /><br />
<input type="file" name="image"/><br />
<input type="submit" name="submit" />
</form>
</body>
</html>
Code for controller
function addInfo($imagetype,$imagedata,$info1,$info2,$info3,$info4,$info5)
{
$addI=$this->conn->prepare('insert into `addinfo` (imagetype,image,info1,info2,info3,info4,info5) VALUES (?,?,?,?,?,?,?) ');
$addI->bind_param("sbsssss",$imagetype,$imagedata,$info1,$info2,$info3,$info4,$info5) ;
$addI->execute();
}
This is just a suggestion.
You could add "required" attribute to your inputs so it won't be submitted if its empty.
This works on latest browser
your code
<input type="text" name="info1" /><br />
<input type="text" name="info2" /><br />
can be
<input type="text" name="info1" required /><br />
<input type="text" name="info2" required /><br />
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I'm making a calculator-like web application that asks for user names, then displays their names on the next page and adds their score. I have three problems:
The user names won't display on the second page
It won't add the score
Whenever you enter a score for player 1, player 2's score is reset to zero, and vise-versia
You can access the page at: ripdvd.x10.mx/index.php
Thanks in advance!
First page:
<!DOCTYPE html>
<html>
<head>
<title>Select Players</title>
<link rel=StyleSheet href="style.css" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<form method="post" action="scoregen.php">
<p class="par">
<label for="player1">Please type in the one of the players first name:</label>
<input type="text" id="player1" name="player1" size="17" maxlength="17" class="textbox" />
</p>
<p class="par">
<label for="player2">Please type in another players first name:</label>
<input type="text" id="player2" name="player2" size="17" maxlength="17" class="textbox" />
</p>
<input type="submit" class="button" name="button" value="Start Playing!" />
</form>
</body>
</html>
Second page(displays scores and provides a way to update them)
<?php
// Get data from HTML form.
//Gets the player names
$player1 = $_POST['player1'];
$player2 = $_POST['player2'];
$addScore1 = $_POST['addScore1'];
$addScore2 = $_POST['addScore2'];
$oldScore1 = $_POST['oldScore1'];
$oldScore2 = $_POST['oldScore2'];
$curr1=$_COOKIE["score1"]+$addScore1;
$curr2=$_COOKIE["score2"]+$addScore2;
setcookie("score1", $_COOKIE["score1"]+$addScore1, time()+3600);
setcookie("score2", $_COOKIE["score2"]+$addScore2, time()+3600);
//Reset cookies if reset button is 't', which makes it clear scores
if ($clse = t){
setcookie ("score1", "", time() - 3600);
setcookie ("score2", "", time() - 3600);
}
// Generate HTML form
?>
<!DOCTYPE HTML>
<html>
<head>
<title>Score Add</title>
<link rel=StyleSheet href="style.css" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<form method="post" action=" ">
<p class="par">
<label for="addScore1">Enter your score, <?php echo $player1; ?>:</label>
<input type="text" name="addScore1" id="addScore1" class="textbox" />
<input type="hidden" name="oldScore1" id="oldScore1" value="<?php echo $oldscore1; ?>" />
<input type="submit" class="button" value="Add Score!" />
</p>
<p class="par">
<label for="addScore2">Enter your score, <?php echo $player2; ?>:</label>
<input type="text" name="addScore2" id="addScore2" class="textbox"/>
<input type="hidden" name="oldScore2" id="oldScore2" value="<?php echo $oldscore2; ?>" />
<input type="submit" class="button" value="Add Score!"/>
</form>
</p>
<form method="post" action=" ">
<input type="hidden" name="clsc" id="clsc" value="t" />
<input type="submit" class="reset" value="Clear Scores" />
</form>
<!--Shows player and score-->
<p class="par"><?php echo $player1;?>:<?php echo $curr1?></p>
<p class="par"><?php echo $player2;?>:<?php echo $curr2?></p>
</body>
</html>
I made several changes to your code (including the removal of cookies - hope that's ok). If you can live without cookies, try this:
<?php
// Get data from HTML form.
// Gets the player names
$player1 = $_POST['player1'];
$player2 = $_POST['player2'];
if ($_POST['addScore1'] == null)
$addScore1 = 0;
else
$addScore1 = $_POST['addScore1'];
if ($_POST['addScore2'] == null)
$addScore2 = 0;
else
$addScore2 = $_POST['addScore2'];
if ($_POST['oldScore1'] == null)
$oldScore1 = 0;
else
$oldScore1 = $_POST['oldScore1'];
if ($_POST['oldScore2'] == null)
$oldScore1 = 0;
else
$oldScore2 = $_POST['oldScore2'];
$curr1=$oldScore1+$addScore1;
$curr2=$oldScore2+$addScore2;
if ($_POST['clse'] == "t"){
$curr1 = 0;
$curr2 = 0;
}
// Generate HTML form
?>
<!DOCTYPE HTML>
<html>
<head>
<title>Score Add</title>
<link rel=StyleSheet href="style.css" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
<p class="par">
<label for="addScore1">Enter your score, <?php echo $player1; ?>:</label>
<input type="text" name="addScore1" id="addScore1" class="textbox" />
<input type="hidden" name="oldScore1" id="oldScore1" value="<?php echo $curr1; ?>" />
<input type="submit" class="button" value="Add Score!" />
</p>
<p class="par">
<label for="addScore2">Enter your score, <?php echo $player2; ?>:</label>
<input type="text" name="addScore2" id="addScore2" class="textbox"/>
<input type="hidden" name="oldScore2" id="oldScore2" value="<?php echo $curr2; ?>" />
<input type="submit" class="button" value="Add Score!"/>
</p>
<input type="hidden" name="player1" value="<?PHP echo $player1;?>" />
<input type="hidden" name="player2" value="<?PHP echo $player2;?>" />
</form>
<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
<input type="hidden" name="clsc" id="clsc" value="t" />
<input type="submit" class="reset" value="Clear Scores" />
</form>
<!--Shows player and score-->
<p class="par"><?php echo $player1;?>:<?php echo $curr1?></p>
<p class="par"><?php echo $player2;?>:<?php echo $curr2?></p>
</body>
</html>
Note, I haven't actually ran this, but try it and let me know if you get any errors or still have problems.
Try this one:
index.php
<!DOCTYPE html>
<html>
<head>
<title>Select Players</title>
<link rel=StyleSheet href="style.css" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<form method="post" action="scoregen.php">
<p class="par">
<label for="player1">Please type in the one of the players first name:</label>
<input type="text" id="player1" name="player1" size="17" maxlength="17" class="textbox" />
</p>
<p class="par">
<label for="player2">Please type in another players first name:</label>
<input type="text" id="player2" name="player2" size="17" maxlength="17" class="textbox" />
</p>
<input type="submit" class="button" name="names" value="Start Playing!" />
</form>
</body>
</html>
scoregen.php
<?php
// Get data from HTML form.
//Gets the player names
if(isset($_POST['player1'])){
$player1 = $_POST['player1'];
}else{
$player1 = "No Player";
}
if(isset($_POST['player2'])){
$player2 = $_POST['player2'];
}else{
$player2 = "No Player";
}
//CHECKS IF THE ADDSCORE BUTTON IS HIT
if(isset($_POST['AddScore'])){
$oldScore1 = $_POST['oldScore1'];
$oldScore2 = $_POST['oldScore2'];
if(!empty($_POST['addScore1'])){
$addScore1 = $_POST['addScore1'];
}else{
$addScore1 = 0;
}
if(!empty($_POST['addScore2'])){
$addScore2 = $_POST['addScore2'];
}else{
$addScore2 = 0;
}
}else{//INITIALIZES THE SCORES TO ZERO; OR SETS IT TO ZERO IF THE CLEAR SCORES BUTTON IS HIT
$oldScore1 = 0;
$oldScore2 = 0;
$addScore1 = 0;
$addScore2 = 0;
}
$curr1 = $oldScore1 + $addScore1;
$curr2 = $oldScore2 + $addScore2;
// Generate HTML form
?>
<!DOCTYPE HTML>
<html>
<head>
<title>Score Add</title>
<link rel=StyleSheet href="style.css" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<form method="post" action=" ">
<p class="par">
<label for="addScore1">Enter your score, <?php echo $player1; ?>:</label>
<input type="text" name="addScore1" id="addScore1" class="textbox" />
<input type="hidden" name="oldScore1" id="oldScore1" value="<?php echo $curr1; ?>" />
<input type="submit" name="AddScore" class="button" value="Add Score!" />
</p>
<p class="par">
<label for="addScore2">Enter your score, <?php echo $player2; ?>:</label>
<input type="text" name="addScore2" id="addScore2" class="textbox"/>
<input type="hidden" name="oldScore2" id="oldScore2" value="<?php echo $curr2; ?>" />
<input type="submit" name="AddScore" class="button" value="Add Score!"/>
</p>
<input type="hidden" name="player1" value="<?php echo $player1;?>"/>
<input type="hidden" name="player2" value="<?php echo $player2;?>"/>
<p class="par">
<input type="submit" class="reset" value="Clear Scores" />
</p>
</form>
<!--Shows player and score-->
<p class="par"><?php echo $player1;?>:<?php echo $curr1?></p>
<p class="par"><?php echo $player2;?>:<?php echo $curr2?></p>
</body>
</html>
1) I did not use cookies here, you don't actually need it for the scores, you can use to save the usernames though.
2) You can actually just have one addScore button, but in this code it doesn't matter. it add the scores anyway.
3) I always check if a an element of the POST is set or if it has a value or not. So i put some checking for the scores and the names.
4) In this line of your code:
<input type="hidden" name="oldScore2" id="oldScore2" value="<?php echo $oldscore2; ?>" />
i changed the $oldscore to $curr, because the $curr score would be needed in the next submit as the oldscore so the score would add up.
$oldScore1 does not equal $oldscore1
and in any case you need to keep the new values to post to the next page
<input type="hidden" name="oldScore1" id="oldScore1" value="<?php echo $curr1; ?>" />
<input type="hidden" name="oldScore2" id="oldScore2" value="<?php echo $curr2; ?>" />
Drop the cookies and just use
$curr1=$oldScore1+$addScore1;
$curr2=$oldScore2+$addScore2;
It's also worth checking if the posts are set to avoid warnings, and making sure they are integers, e.g.
$oldScore1 = isset($_POST['oldScore1'])? (int)$_POST['oldScore1'] : 0;
$oldScore2 = isset($_POST['oldScore2'])? (int)$_POST['oldScore2'] : 0;
I'm beginer to web developing so maybe this is a so easy and stupid question from my side but I tring to find a way to solve this all day and please HELP.
I have a form:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
<!--
body,td,th {
font-family: Calibri;
}
.style1 {font-size: 24px};
-->
#wrapper {
margin: 0 auto;
width:600px;
height:1000px;
margin-top:50px;
background:url(bgMob.jpg);
border:solid;
border-color:#CCCCCC;
}
#inside {
width:920px;
height:1500px;
margin-left:30px;
margin-right:30px;
}
.style2 {color: #CC0000}
.style4 {color: #FF6600}
.style5 {color: #FF0000}
.styleField {
border-radius:5px;
border-width:thin;
border-color:#CCCCCC;
height:30px;
font-family:Calibri;
font-size:16px;
}
.styleField:hover {
background:#CC0000;
font-style:normal;
color:#FFFFFF;
}
.styleButton {
background:#EEEEEE;
border-radius:5px;
border-width:thin;
border-color:#CCCCCC;
height:30px;
}
.styleButton:hover {
background:#CCCCCC;
}
</style></head>
<body>
<div align="center" class="style1 style2"><span class="style5">creator</span><span class="style4"></span></div>
<div id="wrapper"><div id="inside">
<form id="city" name="city" action="<?php echo $_POST["city"]; ?>" method="post">
<label>CITY name :<br />
<input name="city" type="text" class="styleField" size="50" />
</label>
<label>
<input name="city" type="submit" class="styleButton" value="Check!" />
</label>
</form>
<form id="form1" name="form1" method="post" action="">
<label>Enter the site URL:<br />
<input name="textfield" type="text" class="styleField" size="50" />
</label>
<label>
<input name="Submit" type="submit" class="styleButton" value="Check!" />
</label>
</form>
<hr />
<form id="form0" name="form0" method="post" action="">
<label>Enter the URL where is all deals:<br />
<input name="textfield0" type="text" class="styleField" size="50" />
</label>
<label>
<input name="Submit0" type="submit" class="styleButton" value="Check!" />
</label>
</form>
<hr />
<form id="form2" name="form2" method="post" action="">
<label>
Xpath location of links where is ALL deals<br />
<input name="textfield2" type="text" class="styleField" size="50" />
</label>
<input name="Submit2" type="submit" class="styleButton" value="Check!" />
</form>
<hr />
<form id="form3" name="form3" method="post" action="">
<label>
Xpath location of TITLE <br />
<input name="textfield3" type="text" class="styleField" size="50" />
</label>
<input name="Submit3" type="submit" class="styleButton" value="Check!" />
</form>
<hr />
<form id="form33" name="form33" method="post" action="">
<label>
Xpath location of SUB-TITLE <br />
<input name="textfield33" type="text" class="styleField" size="50" />
</label>
<input name="Submit33" type="submit" class="styleButton" value="Check!" />
</form>
<hr />
<form id="form4" name="form4" method="post" action="">
<label>
Xpath location of PRICE <br />
<input name="textfield4" type="text" class="styleField" size="50" />
</label>
<input name="Submit4" type="submit" class="styleButton" value="Check!" />
</form>
<hr />
<form id="form5" name="form5" method="post" action="">
<label>
Xpath location of Original PRICE <br />
<input name="textfield5" type="text" class="styleField" size="50" />
</label>
<input name="Submit5" type="submit" class="styleButton" value="Check!" />
</form>
<hr />
<form id="form6" name="form6" method="post" action="">
<label>
Xpath location of DISSCOUNT <br />
<input name="textfield6" type="text" class="styleField" size="50" />
</label>
<input name="Submit6" type="submit" class="styleButton" value="Check!" />
</form>
<hr />
<form id="form7" name="form7" method="post" action="">
<label>
Xpath location of MAP - latitude, longitude <br />
<input name="textfield7" type="text" class="styleField" size="50" />
</label>
<input name="Submit7" type="submit" class="styleButton" value="Check!" />
</form>
<hr />
<form id="form8" name="form8" method="post" action="">
<label>
Xpath location offer TIME <br />
<input name="textfield8" type="text" class="styleField" size="50" />
</label>
<input name="Submit8" type="submit" class="styleButton" value="Check!" />
</form>
<hr />
<form id="form9" name="form9" method="post" action="">
<label>
Xpath location of BUSINESS name <br />
<input name="textfield9" type="text" class="styleField" size="50" />
</label>
<input name="Submit9" type="submit" class="styleButton" value="Check!" />
</form>
<hr />
<form id="form10" name="form10" method="post" action="">
<label>
<div align="center">
<input name="Submit10" type="submit" class="styleButton" value="Create a scraping file!" />
</div>
</label>
</form>
<hr />
</div>
</div>
</body>
</html>
and I have a second php file who i want to execute with jquery and based on entered xpath in form...
here is:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Scraping - eKupon.ba</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<?php
error_reporting(E_ALL);
require_once('../includes/php.scarping.php');
//Adresa sajta
$scrapeConf['homePage'] = 'http://www.ekupon.ba';
//Adresa gdje se nalaze sve ponude
$scrapeConf['mainURL'] = 'http://www.ekupon.ba/aktivne-ponude/';
//XPATH putanja do linkova od svake ponude ponaosob
$scrapeConf['PonudaLinkovi'] = "//div[#class='pdodatna-naslovbox']/a/#href";
//XPath Putanja do naslova ponude
$scrapeConf['PonudaNaslov'] = "//div[#id='naslovbox']/span[#class='naslov']";
//XPath Putanja do podnaslova ponude
$scrapeConf['PonudaPodnaslov'] = "//div[#id='naslovbox']/span[#class='podnaslov']";
//XPath Putanja do prve slike koju zelimo
$scrapeConf['PonudaSlika'] = "//*[#id='ponuda']//a/img/#src";
//XPath putanja do polja sa cijenom
$scrapeConf['PonudaCijena'] = "//*[#id='ponuda']//div[#class='cijena']";
//XPath putanja do polja sa orginalnom cijenom
$scrapeConf['PonudaOrgCijena'] = "//*[#id='podaci']//span";
//XPath putanja do polja sa orginalnom cijenom
$scrapeConf['PonudaPopust'] = "//table[#id='podaci']//tr[2]/td[2]/span";
//Xpath do dijela koji sadrzi ili <script> sa lat lng ili url sa lat|lng
$scrapeConf['PonudaLatLng'] = "//table[#id='lokacija']//td/script[2]";
//Xpath putanja do elementa koji sadrzi vrijeme do istka ponude
$scrapeConf['PonudaVaziDo'] = "//table[#class='sjena']//span[#class='sat']";
//Xpath putanja do dijela koji sadrzi ime firme (nije obavezno)
$scrapeConf['PonudaFirmaIme'] = "//table[#id='lokacija']//p/strong";
//Xpath putanja do dijela koji sadrzi adresu firme (nije obavezno)
$scrapeConf['PonudaFirmaAdresa'] = "";
//Xpath putanja do dijela koji sadrzi telefon (nije obavezno)
$scrapeConf['PonudaFirmaTel'] = "";
//Xpath putanja do dijela koji sadrzi email (nije obavezno)
$scrapeConf['PonudaFirmaMail'] = "";
//Uzmi sve ponude
$ponudeList = xpathPonude($scrapeConf);
//DODAVANJE PONUDA
foreach ($ponudeList as $key => $ponuda) {
//OVDE obraditi varijable iz ponuda ako ima potrebe...
$ponuda['naslov'] = str_replace(' -', '', $ponuda['naslov']);
//sacuvaj sliku
$imeSlike = date('YMDHM-') . $ponuda['lat'] .'.jpg';
save_image($ponuda['slika'], '/home/pluspon/public_html/slike/'. $imeSlike);
$ponuda['slika'] = $imeSlike;
// DO OVE LINIJE SVE PONUDE I VARIJABLE MORAJU BITI
// SREDJENE I SPREMNE ZA UPIS U BAZU
print insertNew($ponuda['naslov'], $ponuda['podnaslov'], $ponuda['lat'], $ponuda['lng'], $ponuda['slika'], $ponuda['url'], $ponuda['popust'], $ponuda['vaziDo'], $ponuda['firma'], $ponuda['firmaadresa'], $ponuda['firmaemail'], $ponuda['firmatelefon'], $ponuda['firmaURL']);
}
//Debug vreme
print 'Vreme proteklo '. sk_genTime() .' sekundi';
?>
</body>
</html>
also what I want is when user type xpath in form and click on check then get a $result from php file and know is the xpath right or not. Offcource the result print right on the button. I know that can do it with ajax and jquery but I'm not very well in this so I also want to pay to someone who want to help me. And really sorry for my english but I'm working now on my engslih hard.
also I need to replace a text in apostrof (') with value from form...
Add an onSubmit parameter to the form tag, which calls a JavaScript function. That JavaScript function should call the PHP script by using the JQuery post function, and passing it the form data. The success callback of the post function will receive the data returned by the PHP script, and you can put that anywhere on your calling page via the DOM.