Jump to content

Arbu

Members
  • Posts

    39
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Arbu's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. Slightly disconcertingly, though, I find that Notepad++, which I use, doesn't show the code formatting colours when I put the inverted commas around the php. This makes it look as if the code won't work, although clearly it does.
  2. If you want to write a program on your own PC I don't understand why you wouldn't use vb.net or the like. Do people just want the program to operate through their browser? Anyway thanks for the link, I'll have a look. Actually I guess I can just use php instead. All I'm trying to do is make a cURL command so php ought to be adequate. Maybe Python is for full blown applications that run on the server. There's a handy converter here https://reqbin.com/req/java/c-w7oitglz/convert-curl-to-http-request
  3. OK, thanks. But then how do I actually use it? Presumably I have to put something in my file like I do with php: <?php.....?> I have looked over the Python tutorial and I can't see where it tells me this fundamental piece of information. It only seems to talk about using it on my own PC. Maybe I have to use a module and have my Python code separate from my other code? Edit: No it's not that. When I try that I get the message "non-JS module files deprecated".
  4. Arbu

    node.js

    You say that "Node.js uses JavaScript on the server". But your tutorial relates to setting up my own computer as a server and running node on that. I need to use the server from my hosting company. When I try to use node on my website I fall at the first hurdle. I get the error: "Uncaught ReferenceError: require is not defined". How do I ensure that node is running on my hosting provider?
  5. I have some data in the form "I-AHUSH" (it's a Paypal subscription reference). I'm saving it as a $_SESSION variable on the server. When I recover it and do the following, javascript insists on treating it as something to be evaluated. This causes an error. How do I stop it from doing so? You can see that I've tried forcing it to be a string. But that doesn't help. var s = String(<?php echo $_SESSION['subscriptionid'] ?>); Thanks
  6. I think I've got it. You have to specify type="button" for the button. Otherwise it's treated as if the type were "submit".
  7. Er, that's not so good because then none of the data is set to the server. But if I don't have it, the form seems to get submitted before the Paypal instructions are completed. I'd really like to understand what the trigger is for submitting the form. I had thought that it would be done by the user clicking a button with type="submit". But my button doesn't have this type. So what on earth is the trigger? Is it just the fact of hiding the form?
  8. The instructions I was using to do this are now in "quality review" (https://www.wikihow.com/Create-a-Secure-Login-Script-in-PHP-and-MySQL) so I guess I'll have to start again with another set of instructions. It seems incredibly complicated for something that many websites seem to do without any problems.
  9. OK thanks. So the file which includes it does so, as I say, at the beginning, and it contains an html form. Once the user has completed the form and pressed "Submit", the data gets sent to the server. I then want register.inc.php to be run using that data. So it seems that the include statement is placed in a completely inappropriate place in the file. register.inc.php should only be included after the form has been submitted. Otherwise the data won't be there. Should it be included in the form's onsubmit property perhaps?
  10. I've got some code which looks like this: <?php if (isset($_POST['username'],$_POST['first_name'],$_POST['surname'], $_POST['email'], $_POST['p'])) { // Sanitize and validate the data passed in... in a file called register.inc.php. The only references to this file are include_once 'includes/register.inc.php'; in the opening lines of a couple of other files. What is puzzling is just how the php condition gets called. Is it called continuously, so that as soon as the variables have been set, it triggers? Or is it called when the page that includes it is loaded? Whatever, it doesn't seem to be called like a normal function. It all seems a bit mysterious and unexplained. Can anyone help me out? Thanks.
  11. OK, I added this into the form declaration, and it seems to fix it: onsubmit="return false"
  12. Hmm, if I type the code from showpaypal() into the chrome console and execute the lines one by one it all works well. But I'm still getting the same problem with calling this function on the page- the paypal div shows for an instant and then the form details reappear.
  13. I'm trying to set up a registration form with Paypal payment. Once all the data has been entered and verified in the form, the registration form should be hidden and the Paypal form show. But the Paypal form only shows for two seconds before the registration form reappears. What am I doing wrong? I attach code below. Also, I don't understand the lines in regformhash which someone else has written for me. It seems that you can return multiple instructions in one line in a function. But what does the false at the end of each line do? Where does it get picked up? Thanks. <form class="clearfix" method="post" id="registerform" name="registration_form" action="<?php echo esc_url($_SERVER['PHP_SELF']); ?>"> <div class="form" id ="formdetails"> <input class="user" type="text" placeholder="Username" name="username" autocomplete="off"> <input class="first_name" type="text" placeholder="First Name" name="first_name" autocomplete="off"> <input class="surname" type="text" placeholder="Surname" name="surname" autocomplete="off"> <input class="em" type="text" placeholder="Email" name="email" autocomplete="off"> <input class="pass" type="password" placeholder="Password" name="password" autocomplete="off"> <input class="pass" type="password" placeholder="Confirm Password" name="confirmpwd" autocomplete="off"> </div> <div id="clearfix"> <div style="width: 50%; float: right; position: relative; height: 54px;"> <button class="register" onclick="return regformhash(this.form, this.form.username, this.form.first_name, this.form.surname, this.form.email, this.form.password, this.form.confirmpwd);">Continue</button> </div> <div class="terms"> <!-- <label style="line-height: 36px; font-size: 14px; font-family: Lato; color: #4285F4; padding-left: 6px;">Terms and conditions</label> --> </div> </div> <div id="paypal-button-container" hidden ="true"></div> <script src="https://www.paypal.com/sdk/js?client-id=Aa0YBaV1-WR_MAf-ExcJw38f8kwG-Oir7r5xPgbC1Bz1-tgEC4J6UAPNZopfkyBzzE4vMie3WiBdYIyF&vault=true&intent=subscription" data-sdk-integration-source="button-factory"></script> <script> paypal.Buttons({ style: { shape: 'rect', color: 'gold', layout: 'vertical', label: 'subscribe' }, createSubscription: function(data, actions) { //this triggers on the user clicking a Paypal button. return actions.subscription.create({ 'plan_id': '****************' }); }, onApprove: function(data, actions) { document.getElementById("registerform").submit(); } }).render('#paypal-button-container'); </script> </form> <script type = "text/javascript"> function showpaypal(){ document.getElementById("formdetails").hidden=true; document.getElementById("clearfix").hidden=true; document.getElementById("paypal-button-container").hidden=false; return false; } function regformhash(a, b, h, i, c, d, e) { if ("" == b.value ) return swal({title: "Please try again",text: "Please enter your username.",showConfirmButton: true,showCancelButton: false,allowOutsideClick: true}), a.username.focus(), false; if ("" == h.value ) return swal({title: "Please try again",text: "Please enter your first name.",showConfirmButton: true,showCancelButton: false,allowOutsideClick: true}), a.first_name.focus(), false; if ("" == i.value ) return swal({title: "Please try again",text: "Please enter your surname.",showConfirmButton: true,showCancelButton: false,allowOutsideClick: true}), a.surname.focus(), false; if ("" == c.value ) return swal({title: "Please try again",text: "Please enter your email address.",showConfirmButton: true,showCancelButton: false,allowOutsideClick: true}), a.email.focus(), false; if ("" == d.value ) return swal({title: "Please try again",text: "Please enter your password.",showConfirmButton: true,showCancelButton: false,allowOutsideClick: true}), a.password.focus(), false; if ("" == e.value ) return swal({title: "Please try again",text: "Please confirm your password.",showConfirmButton: true,showCancelButton: false,allowOutsideClick: true}), a.confirmpwd.focus(), false; if (f = /^\w+$/, !f.test(a.username.value)) return swal({title: "Please try again",text: "Username must contain only letters, numbers and underscores.",showConfirmButton: true,showCancelButton: false,allowOutsideClick: true}), a.username.focus(), false; if (f = /^[a-zA-Z]*$/, !f.test(a.first_name.value)) return swal({title: "Please try again",text: "First name must contain only letters.",showConfirmButton: true,showCancelButton: false,allowOutsideClick: true}), a.first_name.focus(), false; if (f = /^[a-zA-Z]*$/, !f.test(a.surname.value)) return swal({title: "Please try again",text: "Surname must contain only letters.",showConfirmButton: true,showCancelButton: false,allowOutsideClick: true}), a.surname.focus(), false; if (d.value.length < 6) return swal({title: "Please try again",text: "Passwords must be at least 6 characters long.",showConfirmButton: true,showCancelButton: false,allowOutsideClick: true}), a.password.focus(), false; var f = /(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,}/; if (!f.test(d.value)) return swal({title: "Please try again",text: "Passwords must contain at least one number, one lowercase and one uppercase letter.",showConfirmButton: true,showCancelButton: false,allowOutsideClick: true}), false; if (d.value != e.value) return swal({title: "Please try again",text: "Your password and confirmation do not match.",showConfirmButton: true,showCancelButton: false,allowOutsideClick: true}), a.password.focus(), false; //regardless of whether the last argument here is true or false, the paypal buttons only show for two seconds before the page reverts to show the form details. showpaypal(), true; } </script>
  14. w3 schools says "Python can be used on a server to create web applications." and wikipedia says "Examples of commonly-used, web applications, include: web-mail, online retail sales, online banking, and online auctions.". But why do you need an application on the server to access these things? Surely the information is just held in a database or as variables which you can access with PHP and AJAX? What does Python add? I thought that a web application was something like Google Docs - something that is like a computer program but which you run in your browser. But would that actually run on the server? Surely you are better off with something like that running in the browser because otherwise there will be calls back to the server with every keystroke, which seems very inefficient. So maybe someone can clarify for me. Thanks.
×
×
  • Create New...