Update Angular Record - php

For some reason my mind is wrapping around what the problem is here. I am using Angular with a PHP mysql database. I have done console.log for basically every step of the way and it seems to be working, but the textboxes won't display the information that is already inserted into the database.
This form appears when the update button is pressed:
<div *ngIf="this.isClubEditVisible">
<form #f = "ngForm">
<br><br><br>
{{ account.account_type }}
<label>Club Name </label>
<input type="text" name="school_name" class="form-control input-sm" [(ngModel)]="selectedAccount.account_type" placeholder="Full School Name" autocomplete="off">
<br><br>
<h3>Contact Information</h3>
<label>Contact Full Name</label>
<input type="text" name="contact_name" class='form-control input-sm' [(ngModel)]="selectedAccount.contact_name" placeholder="John Doe">
<br><br>
<label>Contact Email </label>
<input type="text" name="contact_email" class="form-control input-sm" [(ngModel)]="selectedAccount.contact_email" placeholder="name#example.com">
<br><br>
<label>Contact Phone Number </label>
<input type="text" name="contact_number" class="form-control input-sm" [(ngModel)]="selectedAccount.contact_number" placeholder="(000) 000-0000">
<br><br>
<input type="button" (click)="update(f)" class="btn btn-success" value="Update Account">
<input type="button" (click)=" cancel()" class="btn btn-cancel" value="Cancel">
</form>
</div>
This report is initiated by the update button which also calls a function to define what record to edit in the database.
<table border='0' width='100%' style='border-collapse: collapse;'>
<tr *ngFor="let Account_Info of account; let i = index">
<button (click)="selectPolicy(account);this.isClubEditVisible = true;" class="nav-delete" type="button">Edit Account Information</button>
</tr>
</table>
This is the function called by the edit button
selectPolicy(account: Account_Info){
console.log("selected account");
this.selectedAccount = account;
console.log(this.selectedAccount);
}
When I print out the selected account in the console it shows the array correctly. Then I thought the textboxes should update above to display the information correctly. But the textboxes are null. Any suggestions?

Related

Replace form button whit php regex

I have a form an need replace button in my form with another data. I should use php regex and replace it. My form sample this is:
<form name="ialRegister" id="ialRegister" method="post">
<input type="text" name="name" id="name">
<input type="text" name="email" id="email">
<input type="text" name="mobile" id="mobile">
<label data-attr="subtitle" class="smallTxt hidden" for="ialButton10"></label>
<button class="loginBtn ial-submit" name="submit" id="ialButton10">
<span><i class="ial-load" style="visibility: hidden;"></i>
<span data-attr="label">Register</span></span>
</button>
</form>
and I used this regex but it's not working:
$newField = 'custom data';
$form = preg_replace("#(<form.*id=\"ialRegister\".*>.*)
<button.*name=\"submit\".*>.*<\/button>(.*<\/form>)#sU", '$1'.$newField.'$2', $form);
How can do it?

Append table using jQuery with php

Hi every one I'm trying to append a table within a form. But i'm having an error message in console: "Uncaught SyntaxError: missing ) after argument list". When I click the button to add rows it keeps directing me to php script. I Tried to fix it but no luck anyway sorry for bad english, here are the codes.
$('#more_row').append('<tr id="row'+i+'"><td><?php echo "<select name='alpha_num[]' class='form-control' id='item'>"; echo"<option value=''selected disabled>Select Material</option>";while($row = mysqli_fetch_row($result1)){echo"<option value=$row[0]>$row[1]$row[0]</option>";}echo"</select>";?></td><td><input type="text" name="qty[]" class="form-control" id="quantity" placeholder="Qty"></td><td><input type="text" name="uom[]" class="form-control" id="um" placeholder="UOM"></td><td><select name="status[]" class="form-control" id="stat"><option value="approved">approved</option><option value="return">return</option></select></td><td><button id="'+i+'" class="btn btn-danger btn_remove">X</button></td></tr>');
});
$(document).on('click', '.btn_remove', function(){
var button_id = $(this).attr("id");
$('#row'+button_id+'').remove();
});
<div class="panel-body">
<form method="post" action="material_receive_report_process.php">
<div class="row">
<div class="col">
<label for="dr">PO.NO</label>
<input type="text" name="dr_no" class="form-control" id="dr">
</div>
<div class="col">
<label for="dr">DR.NO</label>
<input type="text" name="dr_no" class="form-control" id="dr">
</div>
<div class="col">
<label for="date">Date</label>
<input type="text" name="date" class="form-control" id="date">
</div>
</div>
<table id="more_row">
<tr>
<td>
<?php echo "<select name='alpha_num[]' class='form-control' id='item'>";
echo"<option value=''selected disabled>Select Material</option>";
while($row = mysqli_fetch_row($result1)){
echo"<option value=$row[0]>$row[1]$row[0]</option>";
}
echo"</select>";
?>
</td>
<td>
<input type="text" name="qty[]" class="form-control" id="quantity" placeholder="Qty">
</td>
<td>
<input type="text" name="uom[]" class="form-control" id="um" placeholder="UOM">
</td>
<td>
<select name="status[]" class="form-control" id="stat">
<option value="approved">approved</option>
<option value="return">return</option>
</select>
</td>
<td><button id="add1" class="btn btn-info">Add</button></td>
</tr>
</table>
<br>
<p>Condition:
<input type="checkbox" name="condition[]" value="damage_visible">Damage visible
<input type="checkbox" name="condition[]" value="good_condition">Good conditon
<input type="checkbox" name="condition[]" value="full_qty">Full qty
<input type="checkbox" name="condition[]" value="partial_qty">Partial qty</p>
<div class="form-group">
<label for="supp">Supplier</label>
<input type="text" name="supplier" class="form-control" id="supp">
</div>
<div class="form-group">
<label for="remark">Remarks</label>
<textarea name="remark" class="form-control" id="remark"></textarea></p>
<input type="submit" name="save" class="btn btn-success" value="Save">
</div>
</form>
<br><br>
</div>
</div>
The 'add row' button submits the form because the default value for the type attribute of button elements is "submit". My guess is that the syntax error is due to the mess of single quotes, double quotes, and line breaks that PHP is dumping in your Javascript. Look at the generated code your browser gets. That's what needs to be correctly formed.
The error is most likely due to conflict between Php and JavaScript strings. Consider escaping i.e. \' and using different one for the two say JavaScript use double quotes " while Php use single quotes '

I need a form not to clear the fields during a submit for test mode

I'm writing a php form that has a button to test the database connection before proceeding to the next step. The only problem is that running the test, clears the fields. I can put onsubmit="return false" at the top of the form, but then the test works fine, but I can't submit the form for its real purpose then. I'm guessing this could be fixed with javascript, but I'm a total noob there and I'm wondering if there is a PHP/HTML way to accomplish this.
Here's the form. The test button runs a test pdo connection and gives feedback and the "Next Step >>" button writes the configuration to a file and goes on to the next step.
<H2>Please fill in your database credentials</H2>
<form class="form" action="" onsubmit="return false" method="post">
<label for="dbh">Database Host
<input class="form-control" type="text" name="dbh" value=""></label>
<br><br>
<label for="dbu">Database User
<input class="form-control" type="text" name="dbu" value=""></label>
<br><br>
<label for="dbp">Database Password
<input class="form-control" type="text" name="dbp" value=""></label>
<br><br>
<label for="dbn">Database Name
<input class="form-control" type="text" name="dbn" value=""></label>
<br><br>
<input class="btn btn-success" type="submit" name="test" value="Test Settings">
<input class="btn btn-primary" type="submit" name="submit" value="Next Step >>">
</form>
You need to write in $_POST vars in your inputs.
<label for="dbh">Database Host
<input class="form-control" type="text" name="dbh" value="<? if ($_POST['dbh']){ print $_POST['dbh']; } ?>"></label><br><br>
<label for="dbu">Database User
<input class="form-control" type="text" name="dbu" value="<? if ($_POST['dbu']){ print $_POST['dbu']; } ?>"></label><br><br>
<label for="dbp">Database Password
<input class="form-control" type="text" name="dbp" value="<? if ($_POST['dbp']){ print $_POST['dbp']; } ?>"></label><br><br>
<label for="dbn">Database Name
<input class="form-control" type="text" name="dbn" value="<? if ($_POST['dbn']){ print $_POST['dbn']; } ?>"></label><br><br>

CodeIgniter Form not redirecting properly to paypal

I'm making an ebook online shop with the payment gateway PayPal. Before the user buys my book, I want them to sign up and I want to save their info into my db. This is the code that I've copied from developer.paypal.com.
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<div>
<input type="text" class="form-control" placeholder="First Name" name="buyer_first_name" required id="mailchimp-fname">
<br/>
</div>
<div>
<input type="text" class="form-control" placeholder="Last Name" name="buyer_last_name" required id="mailchimp-lname">
<br/>
</div>
<div>
<input type="email" class="form-control" placeholder="Email" required name="buyer_email" id="mailchimp-email">
<br/>
</div>
<button type="submit" class="btn btn-default">
SIGN UP USING FACEBOOK
</button>
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----MIIHfwYJKoZIhvcNAQcEoIIHcDCCB2wCAQExggEwMIIBLAIBADCBlDCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb20CAQAwDQYJKoZIhvcNAQEBBQAEgYBVbgVO+woc2RO3nt25dc/ecCHPcgXM04uhn+kAIea4MqSCPydnM5+9UwuGNK6IdVMGy6rgqGkwR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Y0WNHn2kDZ0lhfs8DHff28I55oIckGI93aan4aqmtZUGpGvbcF+E5wfXoTStniBgjgGyQ-----END PKCS7-----
">
<input type="submit" name="submit" value="BUY" class="btn btn-default">
</form>
And when the user submits the form it takes me to the checkout from PayPal
Which is good and that's what I want, but I also want to insert their signed form fields into my database so I changed the code a little bit. This is my view code:
<?php echo form_open('welcome/the_buyer')?>
<div>
<input type="text" class="form-control" placeholder="First Name" name="buyer_first_name" required id="mailchimp-fname">
<br/>
</div>
<div>
<input type="text" class="form-control" placeholder="Last Name" name="buyer_last_name" required id="mailchimp-lname">
<br/>
</div>
<div>
<input type="email" class="form-control" placeholder="Email" required name="buyer_email" id="mailchimp-email">
<br/>
</div>
<button type="submit" class="btn btn-default">
SIGN UP USING FACEBOOK
</button>
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----MIIHfwYJKoZIhvcNAQcEoIIHcDCCB2wCAQExggEwMIIBLAIBADCBlDCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb20CAQAwDQYJKoZIhvcNAQEBBQAEgYBVbgVO+woc2RO3nt25dc/ecCHPcgXM04uhn+kAIea4MqSCPydnM5+9UwuGNK6IdVMGy6rgqGkwRInAMA40mgGdfA+nm/5RjvTYAr3ZorvRojc1sYpJt/K/z8YYqRNXE8ohOBni8hEhVY4zdPT908k8HNahi2P3ZpPybqe2PdQjADELMAkGBSsOAwIaBQAwgfwGCSqGSIb3DQEHATAUBggqhkiG9w0DBwQI13xabhbr7+aAgdhmI67QHmKFtDedBgCl1tXuaHjiT4Jav1lMB2bLj0PKUnDZBwees6OiSYdc/H7OVgKiRsngUo+WzNxJFXXM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IFZpZXcxFDASBgNVBAoTC1BheVBhbCBJbmMuMRMwEQYDVQQLFApsaXZlX2NlcnRzMREwDwYDVQQDFAhsaXZlX2FwaTEcMBoGCSqGSIb3DQEJARYNcmVAcGF5cGFsLmNvbYIBADAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4GBAIFfOlaagFrl71+jq6OKidbWFSE+Q4FqROvdgIONth+8kSK//Y/4ihuE4Ymvzn5ceE3S/iBSQQMjyvb+s2TWbQYDwcp129OPIbD9epdr4tJOUNiSojw7BHwYRiPh58S1xGlFgHFXwrEBb3dgNbMUa+u4qectsMAXpVHnD9wIyfmHMYIBmjCCAZYCAQEwgZQwgY4xCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDQTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEUMBIGA1UEChMLUGF5UGFsIEluYy4xEzARBgNVBAsUCmxpdmVfY2VydHMxETAPBgNVBAMUCGxpdmVfYXBpMRwwGgYJKoZIhvcNAQkBFg1yZUBwYXlwYWwuY29tAgEAMAkGBSsOAwIaBQCgXTAYBgkqhkiG9w0BCQMxCwYJKoZIhvcNAQcBMBwGCSqGSIb3DQEJBTEPFw0xNTA2MDYxOTEyNTBaMCMGCSqGSIb3DQEJBDEWBBTmyZ2VXSFUpV0WogL+Mp/Y6CZC1TANBgkqhkiG9w0BAQEFAASBgI4qMxl59Fc9D8gsHZP/+j0sZ8guShv0UqFJg5m51jCPmVTvXDo+r/D1hdWpUUw9zgesPeKg0gacWokehP80YvwUNw/+8NphyiRux1rY0WNHn2kDZ0lhfs8DHff28I55oIckGI93aan4aqmtZUGpGvbcF+E5wfXoTStniBgjgGyQ-----END PKCS7-----
">
<input type="submit" name="submit" value="BUY" class="btn btn-default">
</form>
My controller code:
public function the_buyer(){
$data['buyer_first_name'] = $this->input->post('buyer_first_name');
$data['buyer_last_name'] = $this->input->post('buyer_last_name');
$data['buyer_email'] = $this->input->post('buyer_email');
$this->load->model('buyers_db/buyers');
$this->buyers->insert($data);
redirect('https://www.paypal.com/cgi-bin/webscr');
}
My model code:
public function insert($data){
$this->db->insert('buyers',$data);
}
And now when the user submits the form, the field values are inserting into my database but now the page is redirecting me to this home page
The form needs to submit directly to PayPal, not your site. You will need to utilize the notify url or the return link to process the payment and insert any information in the database.
For more information on PayPal IPN I suggest you check out this link.
You'll want to include any data you want to store in the custom field of the form. I recommend, storing something like the user_id, or an encrypted user_id so that when the notify pings back to your website, you can read what is in custom, and use that to insert data into the database. Please note, this field may be tampered with, so remember to sanitize it, or encrypt it so users can't change the data.
i wasn't redirecting to the right url
redirect('https://www.paypal.com/pe/cgi-bin/webscr?cmd=_flow&SESSION=S-A8TQJiOMvvMRh8VUV6-8W01hNHYgkK0ZVirABunW_IjHIcFecUT9cfGxm&dispatch=50a222a57771920b6a3d7b606239e4d529b525e0b7e69bf0224adecfb0124e9b61f737ba21b08198acc59b45c1b5383c3fbf91319c9514c0');
Thanks for the help everybody

Input string separated by underscore in form

I haven't come to much luck finding anything on this, since I couldn't think how to word it originally.
Basically I have a form, in HTML, the end user will submit a value such as "12345_54321" into 1 input field, then process.
I would like to be able to allow there to be 2 input fields instead, so one of them they would enter "12345" and in the second one, they'd enter "54321".
Which seems easy enough, but my real need is that the "_" must be used as a separator, such as, when the value is submitted, it will process "12345_54321" instead of "12345" and "54321"
My form so far:
<form role="form" method="post" action="process.php">
<fieldset>
<div class="form-group">
<input size="18" type="visible" name="postid" id="postid" class="form-control" placeholder="Enter Story ID Here:" class="input-medium" ><input size="18" type="visible" name="postid" id="postid" class="form-control" placeholder="Enter Comment ID Here:" class="input-medium" >
</div>
<input type="submit" name="submit" class="btn btn-primary btn-large" id="submit_btn" value="Process"/>
</fieldset>
If you want to display 2 inputs for the story id, you have to modify your page to be like so (no need for the underscore (_):
<form role="form" method="post" action="process.php">
<fieldset>
<div class="form-group">
<input size="18" type="visible" name="story_id_1" id="story_id_1" class="form-control" placeholder="Enter Story ID Here:" class="input-medium" >
<input size="18" type="visible" name="story_id_2" id="story_id_2" class="form-control" placeholder="Enter Story ID Here:" class="input-medium" >
<input size="18" type="visible" name="comment_id" id="comment_1" class="form-control" placeholder="Enter Comment ID Here:" class="input-medium" >
</div>
<input type="submit" name="submit" class="btn btn-primary btn-large" id="submit_btn" value="Process"/>
</fieldset>
</form>
In your process.php you can get these variables by looking in your POST.
<?php
$story_id_1 = '';
$story_id_2 = '';
$comment_id = '';
// Check for empty fields
if(isset($_POST['story_id_1']))
$story_id_1 = $_POST['story_id_1']; // From HTML Page
if(isset($_POST['story_id_2']))
$story_id_2 = $_POST['story_id_2']; // From HTML Page
if(isset($_POST['comment_id']))
$comment_id = $_POST['comment_id']; // From HTML Page
print 'Story Id 1: '. $story_id_1 . '</br>';
print 'Story Id 2: '. $story_id_1 . '</br>';
print 'Comment Id: '. $comment_id . '</br>';
Add a hidden field, whose value will be the concatenation of the two input fields:
and on submit, set its value by concatenating the values of the two input fields:
<form role="form" method="post" action="process.php">
<fieldset>
<input type="hidden" id="theValue" />
<div class="form-group">
<input size="18" type="visible" name="postid" id="postid1" class="form-control" placeholder="Enter Story ID Here:" class="input-medium" onchange="concat();">
<input size="18" type="visible" name="postid" id="postid2" class="form-control" placeholder="Enter Comment ID Here:" class="input-medium" onchange="concat();">
</div>
<input type="submit" name="submit" class="btn btn-primary btn-large" id="submit_btn" value="Process" />
</fieldset>
<script>
// if no jQuery.....standard ECMAScript
function concat() {
var val = document.getElementById('postid1').value + '_' + document.getElementById('postid2').value;
document.getElementById('theValue').value = val;
console.log(val);
}

Categories