I'm working on a child theme that uses ultimate member and redefines some of it's functions. Previously it redefined the follow button and sent the info to a payment form and then the form sent the info to a javascript file. The form is no longer used so we are trying to send the info directly to a javascript file and I haven't worked with php in awhile so I'm a little lost. The only options I find are form action and method post which aren't working,
The function is
<div class="um-followers-btn">
<?php
if (in_array("um_customer", $res->roles)) {
$nav_link = UM ()->permalinks()->get_current_url(get_option('permalink_structure'));
$nav_link = remove_query_arg('um_action', $nav_link);
$nav_link = remove_query_arg('subnav', $nav_link);
$nav_link = add_query_arg('profiletab', $id, $nav_link);
And previously the trigger was
echo '<a href="" id="cm_follow_button" data-toggle="modal" data- target="#payment_modal" class="um-button" >Follow</a>';
Obviously this doesn't work so any help would be appreciated.
Apologies, the echo puts forth a "follow" button, what the button appears but what I"m trying to accomplish is for the values, such as user1 and user2 to go to another php file which inserts them into the database and changes the button to request sent this is allhandled in the other php file by the previous team, I'm having trouble sending it there, the previous method was going to a javascript file from the last line above, this line produced the button which when pressed called forth a php form that took payment info, and then sent that to a js form which in turn took theinfo fand verified the payment format, changed the "follow" to "Follow request sent" and sent the rest to a php form that as I said, put the ifo in the mysql database and gave the 2nd user the option of accepting the follow request. Ultimate Member doesn't offer this option which is why it was modified in a child theme like this. We aren't processing payment like this we just want the button to send the info to the php form and I'm having that issue with doing it, via this button. I hope that helps
Related
I have a controller as below
#RequestMapping(value = "/user/{userId}/personal", method = RequestMethod.GET)
public String getUserPersonalInfo(#PathVariable("userId") Integer userId, Model model) throws ServiceBusinessException {
UserBO userBO = userServiceImpl.findUserByUserId(userId);
model.addAttribute("user", userBO);
model.addAttribute("userId", userId);
model.addAttribute("genders", EnumSet.allOf(Gender.class));
model.addAttribute("maritalStatuses", EnumSet.allOf(MaritalStatus.class));
model.addAttribute("ethnicities", EnumSet.allOf(Ethnicity.class));
System.out.println(EnumSet.allOf(Ethnicity.class));
return "personal";
}
Please note the following :
this is a GET call made from the UI to the controller, the controller then processes the request and returns the user along with the other information to the view (personal.html).
Now on the personal.html i need to have a way to edit this user information. thus I am thinking of binding this user data in a th:form tag
this form would then be used to send a post request to the controller to save the changes made by the user.
The problem is that I have not seen any code examples where this has been done. All examples which I have seen, the form is empty and the page is then loaded. user fills up the empty form and click on submit, this information is then stored in the db.
I however on the other hand, is doing something opposite. I need to populate the form with the user object on page load and then on submit this form should be saved in the database.
Can someone guide me to this example please ?
#user641887
While populating the user details on page load, bind data using th:field for a read-only form and when user clicks on edit button make the form fields which are allowed to edit as editable. Now user can edit the required information and save the details.
Sample thymeleaf form code
<input type="text" th:field="*{datePlanted}" />
I've an e-store, one of my payment methods is (Mobile Recharge Cards)
Recently I was doing every thing myself, i receive the recharge number and recharge it on my phone, then mark the order as 'complete' if the number is correct and if not i just ignore it
Now it's too hard to do it, so I searched the web for some solution and i find a one
This webpage:
http://www.stc.com.sa/wps/wcm/connect/english/individual/mobile/prepaid/Charging-Sawa
has a form that send the card balance directly into my phone, and it shows whither the card number is correct or not
So, I'm trying to create an api from this form to recharge the card directly into my phone
I checked this link and i found that it's call another webpage (https://my.stc.com.sa/wps/portal/sawaRecharge/en?cardtype=sawacard&customertype=individual) and include it inside an iframe
I don't want anyone to create the API, all I need is someone who can help me to takeout the (Form Action URL), their system is keep changing the (action="https://my.stc.com.sa/wps/portal/!ut/p/b1/.........") URL each time I refresh the webpage, also they don't even include the Action URL direct in the form tag like this:
<form name="sawaRechargeContestForm" method="post"
action"/wps/portal/!ut/p/b1/......../">
..............................
</form>
BUT, they coded it like this:
First they create an A tag and then include the Action URL of the form, which keep changing every time the page is refreshed:
<a id="wpf_action_ref_3UISawaRechargeSawaPublicUI15d621bb54d174580_1"
href="/wps/portal/!ut/p/b1/......../" style="display:none"></a>
Then they call the form and define it with (_f) variable
_f = document.forms['rechargePublicSawaPageForm'];
Then they add the Action URL from the previous (A tag)
_f.action = document.getElementById('wpf_action_ref_2UISawaRechargeSawaPublicUI15d621bb54d174580_1').href;
I am having a big problem. I have the following tables
db.define_table('post',
Field('user_email', default=auth.user.email if auth.user_id else None),
Field('title', 'string', requires=IS_NOT_EMPTY()),
Field('body', 'text', requires=IS_NOT_EMPTY()),
Field('votes', 'integer', default=0, readable=False, writable=False),
auth.signature
)
db.define_table('comm',
Field('post','reference post'),
Field('body','text'),
auth.signature
)
So basically the user is able to create a post when he is logged in. I want to add the feature of adding comments on a post without reloading the whole page. In this case I would think I have to use the ajax function.
I don't quiet understand the way 'reference' works. I think that when I insert a new text I have to specify which post is coming from, but as I said, I am confused. Can u provide a brief explanation of how to relate the two tables? because I have to code a python function in which I have to specify the comments to be displayed on a specific post.
<div class="well">
<h1>{{=post.title}}</h1>
{{=post.body}}
</div>
{{if field_var_created_by == auth.user_id:}}
Edit Post
{{pass}}
<form>
<div class="form-group">
<label for="comment">Comment:</label>
<textarea class="form-control" rows="5" id="comment"></textarea>
<script>
document.write('hello');
</script>
</div>
</form>
Add Comments
As you can see I retrieved all the data of a post on a view by using a python function in the controller. I want to get the input of text area, put it in the database and then somehow display it on this post.
https://wwu39.pythonanywhere.com/prostudy
I have my website booted up on pythonanywhere. The problem I am having is in the forum page. To access the forum you have to log in. Don't worry I am not going to spam you. This is a small app no one will use. Go to forum, select a post and you will see the problem. The add comment button doesn't do anything yet. I have disabled the user authentication feature to make things easier for you
Web2py load component will be the best solution to your problem, exact same example is explained in
web2py book, read LOAD. If you use web2py component, you don't need to write any javascript code, also you can easily use same component at other places.
Go through the above example. You have to do few changes in table definition, controller and load url.
Add post column to comment schema, just like you did and make post column readable and writable false.
Because you don't want to show that column in form
db.define_table('comment_post',
Field('post','reference post', readable=False, writable=False),
Field('body','text'),
auth.signature
)
Then while embedding load component, pass post id as vars
{{=LOAD('comments','post.load', vars={'post_id': parent_post_id}, ajax=True)}}
Pass parent_post_id from parent controller, in your case i think request.args(0) contains parent id.
In controller, now use post_id passed from load url and set it to field post
def post():
db.comment_post.post.default = request.vars.post_id
return dict(form=SQLFORM(db.comment_post).process(),
comments=db(db.comment_post).select())
Hope this helps.
I'm hoping there is a simple solution to this, or else its possible AJAX time!
I WAS using ClickBank. I had a simple button on my page. That sent the form data to a script, I processed the data, and then added a redirect at end of script to jump to the "pay" link. Nice n' easy
But now I'm switching to "Click2Sell" ... and they have a direct href to their site.
Now I COULD use javascript to read the form data, place it into their "cp_" prefix, and create a super long (about 400 chars) query string and send that to their server, then re-read the data at the IPN stage ...
?country=UK&area=essex&desc=This is the data entered by the user 'whatever'
(but that leads to a little fact that certain parts might need to be escaped(?) such as the spaces and the " ' " or whatever other symbol they enter)
So I devised this method:
<javascript>
function send_data(){
document.user.submit();
return true;
}
</javascript>
<div name="noshowdiv"><object name="noshow"></object></div>
<form method="post" target="noshow" name="user">
<input type="text" name="country">
<input type="text" name="area">
<textarea name="desc"></textarea>
</form>
<img src="xxx" onclick="return send_data();">
In a nutshell, when the button is clicked, it jumps to the function, and submits the form data to my script, and then returns to the hyperlink to submit the second form via the hyperlink.
Two problems: Firstly, the data returned by my script is opening in a new tab rather than the <div>, (I suspect 'cos the submit option loses track of the sending window) and also, I need to get a response from my script which I can then append to the href link.
For example, if the form records the user's data on line 5 on my server, the script will return "id=5" I would then make the hyperlink "click2sell.asp?cp_id=5"
As I've said, I suspect this is a job for Ajax and a HttpRequest ... which is a whole new area to me. Any advice?
For the first problem, it opens a new tab because you have target="no-show" on your form.
For the second problem, if you want to use Ajax, I recommend you use jQuery, it will simplify a lot of the code.
But the best option is probably that you completely remove the direct link to click2sell, and just add a submit button to your form. Post the form to your site, which will store whatever info it needs, assigns an ID, and builds the click2sell URL with the ID in one of the parameters, and redirect to it.
Now how you would do that depends on what server-side language you use.
(I think) I have managed to find a work around, which was using the first option to reconstruct the href link. I couldn't iterate through the form as there are values that don't need to be forwarded. First I get the value, load it into a variable, then use an encode function I discovered online, and then reassign to the form ...
var cp_cc=document.getElementById('cc').value;
var cp_cs=document.getElementById('cs').value; // plus 10 other values
var str='&cp_cc='+encodeURIComponent(cc)+'&cp_cs='+encodeURIComponent(cs)+ // etc
var send_str=document.getElementById('c2s_bn_lnk_36288').href;
document.getElementById('c2s_bn_lnk_36288').href=send_str+str;
The "no-show" was a slip up in my typing! Alas, the answer given above wouldn't work as the Click2sell button also includes two calls to external JS files - and they give you no idea what they do, but is something to do with initializing the button, (it passes the "36288" to the script to do ???). And whilst using "Location: ..\n\n" on my server would redirect to their site, it wouldn't action whatever those external files do. (OK, so I didn't give the full facts, but I didn't want to increase the post size with data I felt didn't relate to problem)
** Now got to amend the listening scripts such that rather than set the ID number up front then jump to C2S, it now waits for C2S to send the data back to me and then sets up the database!!
I tried to make some pages with few forms, where one page pass user inputs by session service in PHP. First page (started with session_start() ) has a form and after submit second page got these inputs and transfer it into session's variables. They appeared in the form of second page. As this page calls itself by click submit button I expected to see again these inputs in form of second page but I didn't! I made this small code just to check what is happened but I saw nothing.
<?php
if(isset($_POST['submit']))
{
echo 'Yes, I remembered quantity of money, it is:' . $_SESSION['bu'];
}
else
{
//not submit? Then collect passed data with POST and put into session vars:
...
$_SESSION['bu']=$_POST['txtbu'];
$_SESSION['bz']=$_POST['txtbz'];
$_SESSION['maxb']=$_POST['txtmaxb'];
echo 'I got money amount of:' . $_SESSION['bu'];
}
?>
After this code is code that include Javascript menu made in Agama Web menu:
<script src="menugta01_agwm_popup_engine.js"></script>
and each time I press submit button in the form of second page all session variables disappeared, no data presented, like they were destroyed! After removing this code everything works fine, but I need this nice looking menu. Did anybody met such "issue" and is possible to fix it? Thank you.