BlockBee API callback issue (Laravel 9) - php

Edit: thanks to the help of Aynber and CBroe, I have come to the conclusion that I (as a novice) was completely offtrack. I will readjust as per their comments. Kind regards, James.
I am having some issues trying to integrate the BlockBee API into my Laravel application. So far, the request to generate a BlockBee payment page works, however, the callback received thereafter is one I cannot get to work.
My code works as follows:
User goes to /billing and uses the form to order credits (works)
An API request is made to BlockBee after which the user is redirected to the generated payment page (works)
The user is able to make a payment (works)
The user should be send to the /payment-complete page (works)
The /payment-complete page should then retrieve the value amount from the BlockBee API and add the credits (does not work and I have no idea how to accomplish this).
The form on the /billing page (works):
<form class="mt-4 p-5 bg-white rounded-lg shadow-md" action="/payment" method="post">
Then on the payment page the URL is requested as follows (works):
<?php
// Get the number of credits and calculate the amount to charge
$credits = $_POST['credits'];
$amount = $credits * 0.02;
$expire_at = time() + 3605; // 3600 seconds = 1 hour
// Set up the BlockBee API request parameters
$query = array(
"apikey" => "[API_KEY_REMOVED_FOR_STACKOVERFLOW]",
"redirect_url" => route('payment-success'),
"value" => $amount,
"item_description" => "Credits",
"expire_at" => $expire_at,
"post" => 0
);
// Send the request to the BlockBee API
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.blockbee.io/checkout/request/?" . http_build_query($query),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$error = curl_error($curl);
curl_close($curl);
// Parse the response and get the payment URL
if ($error) {
echo "cURL Error #:" . $error;
} else {
$response = json_decode($response, true);
$payment_url = $response['payment_url'];
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Payment</title>
</head>
<body>
<div class="text-center mt-8">
<p class="text-gray-600 mb-4">Redirecting you to the payment page...</p>
<p class="text-gray-600 mb-4">If you are not automatically redirected, please click the link below:</p>
<a class="text-blue-600 hover:text-blue-800" href="{{ $payment_url }}" target="_blank">Click here</a>
</div>
<script>
window.location.href = "<?php echo $payment_url; ?>";
</script>
</body>
</html>
I have the following routes in the routes/web.php (billing / payment work, payment-success does not):
Route::get('/billing', function () {
$user = Auth::user();
return view('billing', compact('user'));
})->middleware(['auth', 'verified'])->name('billing');
Route::post('/payment', function () {
$user = Auth::user();
return view('payment', compact('user'));
})->middleware(['auth', 'verified'])->name('payment');
Route::get('/payment-success', function () {
$user = Auth::user();
$credits = $_POST['credits'];
$amount = $credits * 0.02;
// Check if the payment was successful
$status = $_GET['status'];
if ($status == 'success') {
// Add credits to user's credit number
$user->credits += $credits * 50;
$user->save();
}
// Show a message to the user
return view('payment-success', compact('user', 'credits', 'amount', 'status'));
})->middleware(['auth', 'verified'])->name('payment-success');
And the following payment-success.blade.php (does not seem to work):
<!DOCTYPE html>
<html>
<head>
<title>Payment Success</title>
</head>
<body>
<div class="text-center mt-8">
#if ($status == 'success')
<p class="text-green-600 mb-4">Payment successful!</p>
<p class="text-gray-600 mb-4">{{ $credits }} credits have been added to your account.</p>
#else
<p class="text-red-600 mb-4">Payment failed.</p>
#endif
</div>
</body>
</html>
I have tried troubleshooting the problem with ChatGPT but it did not work. Also I tried placing the logic for the callback handling outside of the routes/web.php file but am unsure on how to do so.

Related

Paytm redirect to Callback instead of payment gateway in Symfony

So, I have integrated Paytm in Symfony 5 following this tutorial.
My problem here is, if I remove callback_url parameter from the $paytmParams there I can see the payment gateway but no callback is done ,but still could do a payment. Since Callback_Url is very important when I put back, instead of redirecting to payment gateway it redirects to Callback url returning
TXN_FAILURE
Following is the COntroller:
public function pay(Request $request, SessionInterface $session){
$baseurl = $request->getScheme() . '://' . $request->getHttpHost() . $request->getBasePath();
$containerBuilder = new ContainerBuilder();
// add service into the service container
$containerBuilder->register('helper.service', 'App\Helper\PaytmChecksum');
$paytmParams = array(
"MID" => "midmidmidmidmid",
"WEBSITE" => "WEBSTAGING",
"INDUSTRY_TYPE_ID" => "Retail",
"CHANNEL_ID" => "WEB",
"ORDER_ID" => 1,
"CUST_ID" => 2,
"EMAIL" => 'example#gmail.com',
"TXN_AMOUNT" => 300,
"CALLBACK_URL" => $baseurl.$this->generateUrl('paytmcheckout')
);
// $checksum = $containerBuilder->get('helper.service')->getChecksumFromArray($paytmParams, "&".$this->container->getParameter('paytm_marchent_key'));
$checksum = $containerBuilder->get('helper.service')->generateSignature($paytmParams, 'yfIkKK5nEixN33Y3');
// dump($checksum);
// $session->set('checksum', $checksum);
return $this->render('admission/pay.html.twig',[
'paytmParams' => $paytmParams,
'checksum' => $checksum,
]);
}
/**
* #Route("/paytmcheckout", name="paytmcheckout")
*/
//Paytm payment Response function and also use for databse entry.
public function paytmcheckoutAction(Request $request)
{
$containerBuilder = new ContainerBuilder();
$containerBuilder->register('helper.service', 'App\Helper\PaytmChecksum');
$token = $containerBuilder->get('helper.service')->VerifierChecksum($request);
$status = $request->request->get('STATUS');
$orderId = $request->request->get('ORDERID');
$status_code = $request->request->get('STATUSCODE');
// dump($status_code);
// die;
if($token == "TRUE") {
if ($status == "TXN_SUCCESS") {
$this->addFlash('messsage','Payment has been successful.');
}else{
$this->addFlash('messsage','Payment has been Failed.');
}
}
return $this->redirectToRoute('admission');
}
twig: pay.html.twig
<form method="post" action="https://securegw-stage.paytm.in/order/process" name="f1">
<table border="1">
<tbody>
{% for keyVal, paytmParam in paytmParams %}
<input type="hidden" name="{{ keyVal }}" value="{{ paytmParam }}">
{% endfor %}
<input type="hidden" name="CHECKSUMHASH" value="{{ checksum }}">
</tbody>
</table>
<script type="text/javascript">
document.f1.submit();
</script>
</form>
dumping token is true but status is TXN_FAILURE
in url this
https://securegw-stage.paytm.in/order/process
is seen for a sec and redirects to #Route("/paytmcheckout", name="paytmcheckout")
If I have missed elsewhere then please guide me.. Thank you..

How to redirect to the current searching page after update successfully?

How can I redirect to the current searching page after an update is successful?
Is there any idea where I can learn from? Already google it but can't find one...
Route:
Route::get('/admin/usershiftpattern', 'Admin\UserShiftPatternController#index')->name('usp.index');
Route::post('/admin/usershiftpattern/search', 'Admin\UserShiftPatternController#update')->name('usp.search');
Controller:
public function index(Request $req)
{
$usershiftpattern = [];
$shiftpattern = ShiftPattern::all();
if($req->filled('searching')){
$usershiftpattern = $this->fetch($req);
}
return view('admin.usershiftpattern',
['usps' => $usershiftpattern],
compact('shiftpattern'));
}
public function update(Request $req)
{
$usp_var = UserShiftPattern::find($req->inputid);
$usp_var->shift_pattern_id = $req->inputShiftPatternID;
$usp_var->sap_code = $req->inputSapCode;
$execute = UserHelper::LogUserAct($req, "User Work Schedule", "Update User Work Schedule" .$req->inputid);
$usp_var->save();
return redirect(route('usp.index', [], false))->with([
'feedback' => true,
'feedback_text' => "User Shift Pattern ".$usp_var->shift_pattern_id." has successfully been updated.",
'feedback_title' => "Successfully Updated"
]);
}
View:
<form action="{{ route('usp.search') }}" method="POST">
#csrf
<h4><b>Search User Work Schedule</b></h4>
Okay, your problem is that you are using the same action for 2 different routes, not only URL but also method.
Your fix would be:
Route::post('/admin/usershiftpattern/search', 'Admin\UserShiftPatternController#update')
->name('usp.search');
See how I changed #index to #update. That should do it.

Implementing standard PHP form validation within a Slim application

So I’m trying to implement php server side validation for a registration form. I’m using the slim framework along with twig templates to display the html. I’ve been trying to use this example to achieve this but I think the way I have set up my slim routing is interfering with error messages displaying properly on the registration form.
The way my application works currently is that a user navigates to the registration form page which presents the registration form. This is is shown here:
$app->get('/register', function(Request $request, Response $response)
{
return $this->view->render($response,
'register.html.twig',
[
'css_path' => CSS_PATH,
'landing_page' => $_SERVER["SCRIPT_NAME"],
'action_register' => './register/success',
//'initial_input_box_value' => null,
'page_title' => 'Login App - Register',
]);
})->setName('register');
The 'action_register' => './register/success', represents the form ‘action’ attribute in the html twig form and indicates where and how the form data is processed and the response to the submitted form. This can be seen here: (note that the first few lines of the register/success page is the example used from the guide i’ve been using for php validation)
$app->post('/register/success', function(Request $request, Response $response) use ($app)
{
$nameError = " ";
if(isset($_POST['submit']))
{
if (empty($_POST["username"])) {
$nameError = "Name is required";
} else {
$name = test_input($_POST["username"]);
// check name only contains letters and whitespace
if (!preg_match("/^[a-zA-Z ]*$/",$name)) {
$nameError = "Only letters and white space allowed";
}
}
}
function test_input($data)
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
$arr_tainted_params = $request->getParsedBody();
$sanitizer_validator = $this->get('validate_sanitize');
$password_hasher = $this->get('hash_password');
$tainted_email = $arr_tainted_params['email'];
$tainted_username = $arr_tainted_params['username'];
$tainted_password = $arr_tainted_params['password'];
$model = $this->get('model');
$sql_wrapper = $this->get('sql_wrapper');
$sql_queries = $this->get('sql_queries');
$db_handle = $this->get('dbase');
$cleaned_email = $sanitizer_validator->validate_email($tainted_email);
$cleaned_username = $sanitizer_validator->validate_username($tainted_username);
$cleaned_password = $sanitizer_validator->validate_password($tainted_password);
$hashed_cleaned_password = $password_hasher->hash_password($cleaned_password);
$model->set_user_values($cleaned_username, $cleaned_email, $hashed_cleaned_password);
$model->set_sql_wrapper($sql_wrapper);
$model->set_sql_queries($sql_queries);
$model->set_db_handle($db_handle);
if ($sanitizer_validator->get_validate_messages() == ' ')
{
$model->store_user_details();
$_SESSION["loggedin"] = true;
$_SESSION["username"] = $cleaned_username;
$arr_storage_result_message = '';
echo $sanitizer_validator->get_validate_messages(); //this will be turned into a proper alert prompt at a later date
}
if(isset($_SESSION["loggedin"]) && $_SESSION["loggedin"] === true)
{
return $this->view->render($response,
'display_user.html.twig',
[
'css_path' => CSS_PATH,
'landing_page' => $_SERVER["SCRIPT_NAME"],
//'action_register' => 'index.php/register',
//'initial_input_box_value' => null,
'page_title' => 'Login App - Display',
'username' => $cleaned_username,
'hashed_password' => $cleaned_password,
]);
}
});
The idea is that the user creates an account and is then logged in whereby the 'display_user.html.twig', is displayed. Otherwise error messages regarding form validation should be displayed on the registration form itself. However the registration form is only displayed on the /register page. But the registration form posts the data and processes it on the registration/success page.
So I’m not sure if the php validation guide code is in the wrong place or that my slim routing is incorrect for this purpose of form validation. I think the problem lies in the fact that when the form is submitted it redirects trhe user to a new page namely register/success.
In summary i’m trying to implement php form validation such as this within a slim application using twig templates.
I’ll also include the register.html.twig page of the registration form if that helps:
{% extends 'header_footer.html.twig'%}
{% block content %}
<h3>Register A New Account</h3>
<form method = "post" action = " {{ action_register }} ">
<p>Email: <input type="text" name="email" ><br></p>
<p>Username: <input type="text" name="username" ><br></p>
<span class="error">* <?php echo $nameError;?></span> //code used in the php validation guide
<p>Password: <input type="text" name="password" ><br></p>
<!--<p>Password Confirm: <input type="text" name="password_confirm"><br></p> THIS WILL BE IMPLEMENTED LATER-->
<input type="submit" value="Create Account">
</form>
{% endblock %}
You can't use PHP in Twig like that.
Take a look at these:
Slim-Flash
slim-twig-flash
Slim-Validation
With Flash and Slim-Validation you can achieve your desired error messages.
If you don't want to use the above components then you could simply pass your $nameError variable to the template:
PHP:
return $this->view->render($response,
'display_user.html.twig',
[
'nameError' => $nameError, // HERE
'css_path' => CSS_PATH,
'landing_page' => $_SERVER["SCRIPT_NAME"],
//'action_register' => 'index.php/register',
//'initial_input_box_value' => null,
'page_title' => 'Login App - Display',
'username' => $cleaned_username,
'hashed_password' => $cleaned_password,
]
);
Twig:
{% if nameError %}<span class="error">* {{ nameError }}</span>{% endif %}

jQuery: Comment list disappears on ajax form submission

This may be a bit confusing but I will do my best to explain what I'm trying to achieve.
I have a comment form on each post page, users can submit comments via an ajax form and the submitted comment will be displayed below the form without page reload.
All of this works, until I instruct the comments to show based on their post_id and the current post id I'm viewing.
When I do that, each post will start showing its comments only but when I try to submit a comment, the comment_list.blade.php loads an empty list of comments instead of adding the new comment to the already existing ones. I have to refresh the page manually to be able to see the comments.
I have 4 views for the comments:
leave_a_comment.blade.php (has 2 includes to comment_fields and
comment_list)
comment_fields.blade.php (the comment form)
comment_list.blade.php (the comment list)
cancel_reply.blade.php (to
close a reply window)
EDIT: I think I found the problem. in comment.js the comment_done_handler() function is not returning any data.
So if I comment out $('.comment-list').html(data.comment_list); the comment list doesn't disappear on new submission. But of course the newly added comment isn't visible until I reload the page.
EDIT 2: actually it's data.comment_list that is being returned empty in comment.js comment_done_handler(data) method.
comment.js
$(document).on('click', 'a.post-this-comment', function(){
var form_data = {
'per_page': $('.comments_per_page').val(),
'commenter_parent': $('#commenter_parent').val(),
'commenter_post': $('#commenter_post').val(),
'commenter_comment': $('#commenter_comment').val(),
'postid': $('#postid').val(),
};
var arr = [
'commenter_parent',
'commenter_post',
'commenter_comment',
'postid'
];
for (var i in arr, i < arr.length, i++) {
var elem = arr[i];
form_data[elem] = $('#' + elem).val();
}
// console.log(form_data); // something like => Object {per_page: "some_value", commenter_parent: "some_value", commenter_user_id: "some_value", commenter_comment: "some_value"}
var request = $.ajax({
type: 'POST',
url: 'post_this_comment',
data: form_data,
dataType: 'json'
});
request.done(comment_done_handler);
request.fail(comment_fail_handler);
});
function comment_done_handler(data){
console.log(data); // data is sent from server
$('.comment-content').append($('.reply-content .comment-fields'));
$('.comment-list').html(data.comment_list); // put new list
$('#captcha-image').attr('src', data.captcha); // put new captchas
clear_input_fields();
remove_error_messages(data);
hide_comment_fields();
}
Comment Model
public static function root_comments($postId) {
return self::child_comments(0, 'desc')->where('post_id', $postId);
}
public static function child_comments($parent_id, $order='asc'){
return self::where('parent_id', $parent_id)->orderBy('created_at', $order)->get();
}
public function posts() {
return $this->belongsTo('App\Post');
}
public function user() {
return $this->belongsTo('App\User');
}
CommentController
protected function comment_list($per_page, Request $request, Post $post) {
$postId = $post->id;
$root_comments = Comment::root_comments($postId);
$root_with_replies = $this->include_replies_for($root_comments);
$paginated_comments = $this->paginate($root_with_replies, $per_page, $request);
return $paginated_comments;
}
public function index(Request $request, Post $post){
$view_data = self::view_data($request, $post);
return view('eastgate.comment.leave_a_comment', $view_data);
}
public static function view_data(Request $request, Post $post) {
$instance = new Self;
$per_page = session('per_page')?session('per_page'):config('constants.per_page'); // default per page on opening the comment page
$result['per_page'] = $per_page;
$result['comments'] = $instance->comment_list($per_page, $request, $post);
$result['total_comments'] = $instance->total_comments();
$result['captcha_builder'] = $instance->captcha_builder();
return $result;
}
public function post_this_comment(Request $request, Post $post) {
$comment = new Comment;
$comment->user_id = Auth::id();;
$comment->comment = Input::get('commenter_comment');
$comment->post_id = Input::get('commenter_post');
$comment->parent_id = Input::get('commenter_parent');
if($comment->parent_id > 0){
$my_parent = Comment::find($comment->parent_id);
$comment->parents = $my_parent->parents.'.'.$comment->parent_id;
}else{
$comment->parents = '0';
}
$comment->save();
$per_page = Input::get('per_page');
$comment_list = view('eastgate.comment.comment_list')
->with('comments', $this->comment_list($per_page, $request, $post))
->with('total_comments', $this->total_comments())
->with('per_page', $per_page)
->render();
$response = array(
'status' => 'success',
'msg' => 'Comment Saved!',
'comment_list' => $comment_list,
'captcha' => $this->captcha_builder()->inline()
);
return Response::json($response);
}
comment_fields.blade.php
<div class="comment-fields">
<div class="row commenter-comment">
<div class="form-group col-md-12">
<textarea id="commenter_comment" name="commenter_comment" class="form-control comment-field" title="User's comment" placeholder="Comment Text"></textarea>
</div>
</div>
<div class="row commenter-name-email">
<input type="hidden" id="commenter_parent" name="commenter_parent" class="commenter-parent" value="0">
<input type="hidden" id="commenter_post" name="commenter_post" class="commenter-post" value="{{ $post->id }}">
</div>
<div class="row commenter-captcha">
<div class="col-md-3">
Comment
</div>
</div>
</div>
comment_list.blade.php
<div class="comment-list">
<div class="row">
<div class="col-xs-12">
<h2>{!! $total_comments !!} comment(s) </h2>
#foreach($comments as $each_comment)
<?php
$name_for_display = $each_comment->user->name;
$date_for_display = $each_comment->created_at->diffForHumans();
$parent_name_for_display = '';
if($each_comment->parent_id > 0){
$parent_comment = $each_comment->parent();
$parent_name_for_display = $parent_comment != null && $parent_comment->name
? $parent_comment->name : 'Anonymous';
$parent_name_for_display = '<span class="glyphicon glyphicon-share-alt" title="Reply to"> </span>'.$parent_name_for_display;
}
$parents_count = substr_count($each_comment->parents, '.');
$offset_length = $parents_count;
$comment_length = 12 - $offset_length;
?>
<div class="col-xs-offset-{!! $offset_length !!} col-xs-{!! $comment_length !!}">
<input type="hidden" id="postid" name="postid" class="post-id" value="{{ $each_comment->post_id }}">
<ul class="list-inline">
<li class="comment-by">{!! $name_for_display !!}</li>
#if($parents_count > 0)
<li class="reply-to">{!! $parent_name_for_display !!}</li>
#endif
<li class="separator"></li>
<li class="comment-on">{!! $date_for_display !!}</li>
</ul>
<p>{!! $each_comment->comment !!}</p>
Reply
<div class="reply-content reply{!! $each_comment->id !!}"></div>
<hr>
</div>
#endforeach
</div>
</div>
<div class="row">
<div class="col-xs-12">
{!! $comments->render() !!}
</div>
</div>
<div class="row">
<div class="col-xs-12">
Show <input type="text" name="comments_per_page" class="comments_per_page" value="{!! $per_page !!}" size="2" title="Number of comments per page"> comments per page
</div>
</div>
</div>
Please note that if I remove where('post_id', $postId) from Comment Model, it will start working and reloads the correct comment_list with the newly added comment.
I hope that makes sense, and shows the problem I'm facing.
I didn't attempt to execute the code, but this is suspicious:
public static function root_comments($postId) {
return self::child_comments(0, 'desc')->where('post_id', $postId);
}
public static function child_comments($parent_id, $order='asc'){
return self::where('parent_id', $parent_id)->orderBy('created_at', $order)->get();
}
root_comments(referenced in the controller's comment_list action) is chaining child_comments. Except child_comments does not return a query builder object, it returns a collection. You need to remove the get() call from child_comments, and instead only use get() when you're completely done with building your query.
Also, check out query scopes which is a much nicer way of accomplishing what you are trying to do.
Edit 1 - Example (using scopes):
I did not run this code, so there my be syntax errors. This is to better explain the concept.
//First, you need to create scopes on the model
public function scopeByParent($query, $parentId, $order = 'asc') {
return $query->where('parent_id', $parentId)->orderBy('created_at', $order);
}
public function scopeForPost($query, $postId) {
return $query->where('post_id', $postId);
}
//Then, change your existing methods...
public static function root_comments($postId) {
return self::byParent(0, 'desc')->forPost($postId)->get();
}
public static function child_comments($parent_id, $order = 'asc') {
return self::byParent($parent_id, $order)->get();
}
Now these are both returning collections as you'd expect. And you can reuse these scopes elsewhere when you need to retrieve the comment records.
Edit 2:
The above is part of the problem. The second part of the problem is that you were never retrieving the post that the comment was posted for. I made this change locally and it started to work:
public function post_this_comment(Request $request, Post $post) {
//...
$per_page = Input::get('per_page');
//After line 148. The $post that is created by the IoC container is just a reference to the class. You still must load the post from the DB to get the proper data from it.
$post = $post->find($request->commenter_post);
$comment_list = view('eastgate.comment.comment_list')
//...
}
EDIT:
Try this:
public static function root_comments($postId) {
return self::child_comments(0, 'desc')->where('post_id', $postId)->get();
}
-- Before edit ---
Your comment_done_handler doesn't fetch the newly created comment list.
You should make another ajax request inside, or maybe as a separate function
function comment_done_handler(data){
var data = $.ajax({
// ......
// params sent for this request to comment_list controller method
data: {
per_page: 10,
request: request,
post: post_id
},
type: 'GET',
url: 'comment_list'
// ......
}).done(function() {
// ....
}).fail(function(){
// ....
});
console.log(data); // data is retrieved from server
$('.comment-content').append($('.reply-content .comment-fields'));
$('.comment-list').html(data.comment_list); // put new list
$('#captcha-image').attr('src', data.captcha); // put new captchas
clear_input_fields();
remove_error_messages(data);
hide_comment_fields();
}

Form refuses to submit in Codeigniter

Ok i'm going nuts about this issue, I can't get this form to submit, it just refreshes the page.
I've coded it exactly the same as other forms on my site, which work fine. I can't understand why it's not submitting!
Here's the controller:
public function edit($id)
{
// check for login, if logged in
if($this->session->userdata('logged_in') == "1")
{
// Check usertype, if not correct, redirect
if($this->session->userdata('usertype') == "0" || $this->session->userdata('usertype') == "1" || $this->session->userdata('usertype') == "2")
{
// if no photos are selected, redirect and show notification
$this->session->set_flashdata('notification_fail', '<p style="text-align:center; color:#fbfbfb;">You do not have permission to access that page!<p>');
redirect('/');
}
else
{
// get the copy details
$data['copy_details'] = $this->quickcopy_model->get_copy_details($id);
if ($_POST)
{
// get data from the submitted form
$title = $this->input->post('title', TRUE);
$copy = $this->input->post('copy', TRUE);
// update the row in the db
$this->quickcopy_model->edit_go($id, $title, $copy);
// redirect and show notification
$this->session->set_flashdata('notification', '<p style="text-align:center; color:#fbfbfb;">That copy was updated!<p>');
redirect('quick-copy');
die;
}
// load views
$this->load->view('templates/header', $data);
$this->load->view('quickcopy/quickcopy_edit', $data);
$this->load->view('templates/footer', $data);
}
}
else
{
// redirect to signin page if not logged in
redirect('signin');
}
}
And the function being called from the model:
public function edit_go($id, $title, $copy)
{
$data = array(
'title' => $title,
'copy' => $copy
);
$this->db->where('id', $id);
return $this->db->update('quickcopy', $data);
}
And finally the view:
<? echo form_open('quickcopy/edit/'.$copy_details->id); ?>
<p>Title/tagline:</p>
<input type="text" class="Form_Input" id="title" name="title" value="<? echo $copy_details->title; ?>" />
<p style="margin-top: 10px;">Copy:</p>
<textarea id="copy" name="copy" class="Form_Textarea" style="width: 970px"><? echo $copy_details->title; ?></textarea>
<button type="submit" class="Form_SubmitButton"><p style="color: #f7f7f7; text-align: center;">Save changes</p></button>
</form>
I realise i've not done form validation on this, but I have another form where I have used form validation and it won't work either!
Been totally confused about this for 2 days now, I don't get why it's not submitting. The code all looks fine to me, what other reason could there be for a form to not submit? I just installed an SSL but I have other forms that work fine so i'm assuming it's not the SSL.
Any help is most appreciated :)
OK i've managed to figure out what the issue was...at last!
Basically I have some sections of the site protected by SSL and others are not. I forgot to add the new form sections into the SSL in the htaccess file.
Working now.

Categories