I am using Bootstrap with jQuery and I'm facing issues when passing values from FORM to PHP, in this case the same page.
My code is:
<tr>
<td><input type="text" name="descricao[]" ></td>
<td><span class="spanpreco"><input type="text" name="quantidade[]" ></span></td>
<td><span class="spanpreco"><input type="text" name="preco[]"></span></td>
<td><input type="text" name="subtotal[]" disabled></td>
</tr>
Then my jquery goes like this:
$("#adicionar").click(function(){
$("#linha").append('<tr><td><input type="text" name="descricao[]"></td><td><span class="spanpreco"><input type="text" name="quantidade[]" ></span></td><td><span class="spanpreco"><input type="text" name="preco[]"></span></td><td><input type="text" name="subtotal[]" disabled></td></tr>');
});
The problem here is when I post the data to php, every single column that I dynamically add to the form will not pass to PHP, the result number of rows is always one.
Can someone help me here?
I found the issue, the <FORM></FORM> was on the wrong place.
Thanks and best regards,
Adelmo
Related
I have created a blog using PHP that submits a form into a MySQL databse. It works perfectly. What i want to know is how to get it to recognise when i've pressed enter to create a new line or to record a ' without getting a MySQL error. Basically i want to turn a normal submission form into a submission form like is used on this website.
<tr>
<td>Blog Title:</td>
<td><input type="text" id="edt" name="BlogTitle"></td>
</tr>
<tr>
<td>Blog Content:</td>
<td><textarea name="BlogCont" cols="50" rows="10" id="edt"></textarea></td>
</tr>
<tr>
<td><input type="hidden" name="Name" value="<?=$_SESSION['Name']?>"></td>
<td><input type="submit" id="but" value="Post"></td>
</tr>
Any help would be appreciated.
For new lines with enter use nl2br (manual), for apostrophe you have to escape it with mysql_real_escape_string (manual).
I am trying to integrate wordpress CF7 with a third party CRM.
I managed to send the data to the CRM using the following filter:
add_filter('wpcf7_form_action_url', 'wpcf7_custom_form_action_url');
function wpcf7_custom_form_action_url()
{
return 'https://www.myapps-systems.com/api/WebToLeed.asp';
}
Basically what i did is changing the "form action" from the regular CF7 to the WebtoLead action.
I also mapped the Cf7 form with the following attributes (taken from the CRm sample form):
[hidden mbp1 "222626"]
[hidden URLToReturn "http://thankyoupage.com/thankyou"]
[hidden Companies_Account_Status_Code "546"]
[hidden Companies_Company id:Companies_Company "Website Enquiry"]
<div>
[text* Contacts_Contact id:Contacts_Contact class:name]<label>name*:</label>
[tel* Companies_PhoneNumber id:Companies_PhoneNumber class:telelabelhone]
<label>phone*: </label>
[email Companies_Email id:Companies_Email class:email]<label> mail:</label>
[textarea Companies_Note 50x8 id:Companies_Note]<label>message:</label>
</div>
[submit onclick="return OnButton1(); id:send_contact class:submit]
So this did work for me and i managed to receive the data on the CRM, but as i need the data to be stored in the wordpress database as well, i would like it to be both send to the CRM and keep the regular wordpress functionality.And as I cannot use 2 "actions" in 1 form i have to use some different way.
I was trying to implement this by using a few methods , like using "wpcf7_before_send_mail" hook or "wpcf7_after_send_mail", and even using a 3'rd party integration plugin for CF7 (http://wordpress.org/plugins/contact-form-7-3rd-party-integration/screenshots/)
but unfortunatly with ot much success.
I would greatly appreciate your help on the matter.
Here is the full code of the sample Crm integration
<!--
URL is in action attribute.
For all inputs the name attribute is used by the back-end system so don't change them
-->
<form id="big_contact_form" name="Web2LeedForm" action="https://www.myapps-systems.com/api/WebToLeed.asp" method="POST" onsubmit="return submitForm();">
<input type="hidden" name="mbp1" value="222626"/>
<input type="hidden" name="URLToReturn" value="http://test.co.il/contact/thankyou"/>
<input type="hidden" name="Companies_Account_Status_Code" value="546" /> <!-- must be exactly this name and value -->
<input type="hidden" id="Companies_Company" name="Companies_Company" value="website enquiry"/> <!-- the Companies_Company field is mandatory, we don't use it so we just fill it with a value -->
<table>
<tr>
<td>*</td>
<th class="form_label"><label for="Contacts_Contact">name: </label></th>
<td><input class="input" type="text" id="Contacts_Contact" name="Contacts_Contact"/></td>
</tr>
<tr>
<td>*</td>
<th class="form_label"><label for="Companies_PhoneNumber">phone: </label></th>
<td><input class="input" type="text" id="Companies_PhoneNumber" name="Companies_PhoneNumber"/></td>
</tr>
<tr>
<td></td>
<th class="form_label"><label for="Companies_Email">mail: </label></th>
<td><input class="input" type="text" id="Companies_Email" name="Companies_Email"/></td>
</tr>
<tr>
<td></td>
<th class="form_label"><label for="Companies_Note">message:</label></th>
<td><textarea id="Companies_Note" name="Companies_Note" rows="8" cols="50"></textarea></td>
</tr>
<tr>
<td></td>
<td><input id="send_contact" name="submit" type="submit" value="שלח" /></td>
</tr>
</table>
</form>
Thank you
I managed to fix the problem using this great plugin:
http://wordpress.org/plugins/contact-form-7-3rd-party-integration/screenshots/
needs some modification but works great.
So I am at my wits end. Out of the more complex issues, this is the one that has just stumped me. I'm not sure if it's a HTML issue or a PHP issue, anymore. I've tried everything I could think up, and just nothing.
Ok so I need to pull a specific name out of a dynamically created table, the Weapon’s Name to be exact.
So User clicks the button “Delete weapon” and that weapon would be deleted. The query is fine; my issue is getting this name. If there was just one weapon and this wasn’t dynamic I would just go for the specific field name. That’s PHP 101.
This is the loop it's being pulled from:
while ( $weapons = mysql_fetch_array($data)) {
echo '
<table width="780" border="1">
<tr>
<td colspan="2">weapon</td>
<td>AttackBonus</td>
<td>crit</td>
</tr>
<tr>
<td colspan="2">
<input type="text" name="weaponName'.$i.'" id="weaponName'.$i.'" size="10" value="'.$weapons["weaponsName"].'" />
<input type="hidden" name="weaponName" value="'.$weapons["weaponsName"].'"/>
</td>
<td>
<input type="text" name="attackBonus'.$i.'" id="attackBonus'.$i.'" size="10" value='.$weapons["weaponsAttackBonus"].' />
</td>
<td>
<input type="text" name="crit'.$i.'" id="crit'.$i.'" size="10" value='.$weapons["weaponsCritical"].' />
</td>
</tr>
<tr>
<td>type</td>
<td>range</td>
<td>ammunition</td>
<td>damage</td>
</tr>
<tr>
<td>
<input type="text" name="type'.$i.'" id="type'.$i.'" size="10" value='.$weapons["weaponsType"].' />
</td>
<td>
<input type="text" name="range'.$i.'" id="range'.$i.'" size="10" value='.$weapons["weaponsRange"].' />
</td>
<td>
<input type="text" name="ammunition'.$i.'" id="ammunition'.$i.'" size="10" value='.$weapons["weaponsAmmunition"].' />
</td>
<td>
<input type="text" name="damage'.$i.'" id="damage'.$i.'" size="10" value='.$weapons["weaponsDamaage"].' />
</td>
</tr>
<tr>
<td colspan="4">
<input type="submit" formaction="include/deleteweapon.php" formmethod="post" value="Delete Weapon"/>
</td>
</tr>
</table>
';
$i++;}
It’s probably something small, that’s how it’s always been my issue. I’ve tried a few different while loops. I’ve tried if statements with issets($_post[“weaponName0”], etc. I just don’t know.
Edit:
So I'm not very good with explaining what I need. The loop to display the information is fine, and yes the button needs to be there.
(I don't have enough rep to up load an image so here is the link)
http://farm9.staticflickr.com/8391/8468562067_0cd4158e35_b.jpg
This is what it looks like. I can not get the value of the weapon name. The output is fine here, it's when I need to delete that specific weapon, that I'm having issue with. I need that name. This is why I'm not sure if it's the HTML or the PHP. The button has to be iterated or whats the point? The mySQL is fine, that was the easy part.
I have an idea of what I can do, but in my opinion it's bad design and I think I would just have the same problem. I could add a check box for these fields to delete, and it'll be deleted after you try to save the character.
I'm not 100% sure I understand your problem, I believe in your HTML, you should do something like:
<input type="hidden" name="weaponName[<?php print $i; ?>]" value="The Name" />
In your PHP, you should be able to access the name given an index:
$index = 1; // Some arbitrary index
$weapon_name = $_POST['weaponName'][$index];
Alternatively, and what I would do: In your form's action, specify an id:
<form action="delete.php?id=<?php print $weaponId; ?>" action="post">
Then in your PHP, you can do:
$id = $_GET['id']; // This is the weapon ID
Then you can just pull the name directly from the database, using the ID.
It looks like you have a single delete button for each iteration of the loop. You should be able to set the name for deletion just as you set it as a label.
<input type=hidden name=weaponsName value=".$weapons['weaponsName'].">
<input type=submit ...>
$weaponsName = $_POST['weaponsName'];
You are using mysql_fetch_array instead of mysql_fetch_assoc, so you should use the field index, like this:
$weapons["weaponsName"] // This is wrong
$weapons[0] // This is the right approach
PS: You should not use the mysql extension....go for the mysqli or PDO ;)
Saludos.
I have a function allowing members to update their personal details when they have logged in, the update page features a form the user will fill in and when the submit button is pressed the deatils are updated. This works fine, I am wanting to display the users current details in the appropriate text filed in the form e.g. the firstname text field will have value "James" and the user can delete this to enter "jim". Is it something to do with adding a value to the form field? My form is shown below.
<tr>
<td width="78">Firstname</td>
<td width="6">:</td>
<td width="294"><input name="firstname" type="text" id="firstname"></td>
</tr>
<tr>
<td width="78">Surname</td>
<td width="6">:</td>
<td width="294"><input name="surname" type="text" id="surname"></td>
</tr>
Any help is much appreciated
Print value inside the text box.
<input type="text" value="<?php echo $someValue; ?>" />
echo '<input type="text" value="'. $someValue .'" />';
OR
<input type="text" value="<?php echo $someValue; ?>" />
Both obviously require that you be in a .php file, and that $someValue contains the appropriate value to set. Watch out for the double quotes around the value, too. Without them, any spaces will break the value when it's rendered.
Suppose I have a application form which contain lot of boxes like email,username,age etc...I have connected this application form to database(mysql) through action="register.php" in application form...
NOw i want that in database,username and email id should be unique.Means no two users cant have same username or email id..
What I know to do This....
When you created tables in mysql then make these fields (username,email) unique(by primary key).Butif i submit the form with same username already in database then error msj will be showed on the next page something like this.username is priamry.....whatever..
Problem in this...
The error msj should be displayed on the onblur event of that textbox(username textbox and email textbox)..
How i can do this.Please explain with example For your ease i am giving code for application form...something lik ethis
applicationform.php
form name="form" action="register.php" method="GET" >
<tr>
<td>Username</td>
<td><input type="text" id="username" size="30" maxlength="35" value=""></td>
<td><div id="p1"></div></td>
</tr>
<tr>
<td>Email</td>
<td><input type="text" id="email" size="30" maxlength="30" value=""></td>
</tr>
<tr>
<td align="center" colspan="100"> <input type="submit" name="submit" value="Submit">
</td>
</tr>
I think you have to make an Ajax request when the blur event happens and check at the server side whether the the username exists or not.
This AutoCompleter tutorial should give you the right idea how to do this.