Jump to content

XRS

Members
  • Posts

    22
  • Joined

  • Last visited

Everything posted by XRS

  1. Yeah thanks. I think I already got a simple solution that can do the same thing, but not totally editable from admin backend. But thats not really a problem. Thanks all of you.
  2. Ive been searching about that, but for example if I want (another example ) of making an adsense revenue sharing website? There are colors sizes and many publishers ids.. I dont think that with classes it,could be a good thing, because my template have colors (that i can change dinamically without change all template) and ad size will be diferent for any kind of dinamic content.
  3. As I said, its a simple example because my final code is not static. I want to easily manage all data from an admin backend. For example I want a user to choose a color and ill use that user color, but my html code, isnt always the same, changing position, size etc.. so if I have 1000 colors, positions and sizes, I cant store them all in database and choose thr rigth one to display, being an never ending task.
  4. Hello, I need help with one thing, that relies in how to insert dynamic data in a middle output in something from database. A simple example could be: <div align="SOMETHING">blah blah</div> Basically i want to have a field in my database with the div, and another one with the align settings (center, rigth...) . Now, in the output, how can output the align inside the ouput of the div? This is a basic example because there are more things to rule (size, color, position) so its not good to paste the code in html and then only the specs(color,position) by datase output. Can anyone help me getting there because Im having some problems doing so? Thanks.
  5. Hi, Basically I would like to do it because I want to develop a simple link shortener. It could easier if a have a link mysite.com/3Xc than mysite.com/13410394808 ( for eg. ) . I'll try to get into it. Thanks
  6. Hello, I'm in trouble with alphanumeric autoincrement. I have a database wich I need an ID ( the autoincremented one ). It will have many rows, so I'd like to have the smallest ID possible. For example, normally, using only numbers from 0 to 10000000 this ID will be very long. If the ID could have letters, it could be something like 3AcB2 . For example what I'd like to: 1 2 3 4 .... 99 1a 1A 1b 1B .... 999 9aa 9AA 9aA 9Aa and so on... Could someone help me generate me such ID's being last in dabase + 1 ? Thanks in advance.
  7. Hello, Thanks. That worked very well. It's now solved and working like a charm =D
  8. Hello, After made my first form with success validations, now I have a problem that I would like get some help. I made two remote scripts to check if username and e-mail exists in the database ( prevent duplicate registers ). The script works good, but only show a message ( after X seconds ) if the user/email is already registered. I'd like to show a "Checking.." message or a preloader gif while it runs the remote script and after that if the user is OK show a message too. There are my scripts: This is my templating for showing errors: $.validator.setDefaults( { showErrors: function(map, list) { this.currentElements.parents('label:first, .controls:first').find('.error').remove(); this.currentElements.parents('.control-group:first').removeClass('error'); $.each(list, function(index, error) { var ee = $(error.element); var eep = ee.parents('label:first').length ? ee.parents('label:first') : ee.parents('.controls:first'); ee.parents('.control-group:first').addClass('error'); eep.find('.error').remove(); eep.append('<p class="error help-block"><span class="label label-important">' + error.message + '</span></p>'); }); //refreshScrollers(); } }); This is my validation script: $(function() { // validate signup form on keyup and submit $("#registerform").validate({ rules: { firstname: "required", lastname: "required", username: { required: true, minlength: 3, remote:{ url: "inc/core/check_user.php", type: "post", data: { username: function(){ return $( "#username" ).val(); } } } }, password: { required: true, minlength: 5 }, confpassword: { required: true, minlength: 5, equalTo: "#password" }, scode: { required: true, minlength: 4, maxlength: 6, digits: true }, scodeconf: { required: true, minlength: 4, maxlength: 6, digits: true, equalTo: "#scode" }, email: { required: true, email: true, remote:{ url: "inc/core/check_email.php", type: "post", data: { email: function(){ return $( "#email" ).val(); } } } }, topic: { required: "#newsletter:checked", minlength: 2 }, agree: "required", address: "required", zipcode: "required", city: "required", state: "required", country: "required", data: "required", age: "required" }, messages: { firstname: "Please enter your First Name", lastname: "Please enter your Last Name", username: { required: "Please enter a username", minlength: "Your username must consist of at least 3 characters", remote: "Username already exists. Please choose another." }, password: { required: "Please provide a password", minlength: "Your password must be at least 5 characters long" }, confpassword: { required: "Please provide a password", minlength: "Your password must be at least 5 characters long", equalTo: "Please enter the same password as above" }, email:{ required: "Please enter a valid email address", remote: "That e-mail is already registered with us" }, agree: "Please accept the Terms of Service", address: "Please insert your address", zipcode: "Please insert your zip code", city: "Please insert your city", state: "Please choose your state", country: "Please choose your country", data: "Please confirm all information above is correct", age: "Please confirm that you are able to sell or buy products online.", scode: { required: "Please insert a security code", minlength: "Your security code needs to have at least 4 digits", maxlenght: "Your security code can have a maximum of 6 digits", digits: "Your security code only can have digits" }, scodeconf: { required: "Please insert a security code", minlength: "Your security code needs to have at least 4 digits", maxlenght: "Your security code can have a maximum of 6 digits", digits: "Your security code only can have digits", equalTo: "Please enter the same security code as above" }, } }); And my checking script ( this is for username, but it's the same thing only change the data: <?php if(isset($_POST['username'])){ include("/config.php"); $username = validar($_POST['username']); $query = mysql_query("SELECT * FROM utilizadores where username='$username'") or die(mysql_error()); $row = mysql_num_rows($query); if($row == "0"){ echo "true"; }else{ echo "false"; }} ?> Now, my question is, how to show a success message ( if the username is available ) and how to show a loading message ( while the remote script is running ). Can anyone help me ? Thanks!
  9. Hello, I have that validation in a different file. There's anyway to show me an example how could be parsed? My knowledge about JS/Ajax is not great and I'd like to have an example to try it out. Thanks.
  10. Hello, I'm here with a question that maybe silly for most of you but I just can't handle it. As I know, there's no way in built in PHP inside JS because diferent kind of languages ( Server Side and Client Side ). But I have a problem that I need help to handle. I have a multilanguage system in my site ( PHP ) and form validations ( JS ). I have the error messages showed by JS instantly, but I can only print text, not a PHP variable info. For example: $(function() { // validate signup form on keyup and submit $("#loginform").validate({ rules: { user: "required", password: "required", }, messages: { user: "Please enter your username or email.", password: "Please enter your password", } }); }); And my multilanguage system uses the following system: $lang['login_error'] = 'Incorrect details provided.'; There is any way to make something like this: $(function() { // validate signup form on keyup and submit $("#loginform").validate({ rules: { user: "required", password: "required", }, messages: { user: <?php echo $lang[login_error']; ?>, password: "Please enter your password", } }); }); I know this doesn't work, but it's to make an easy example in what I need, because depending the language the user as choosen, the error should be there in that language, not only in one language. Could you please help me to handle this ? Thanks in advance.
  11. Hi, yes, I tried post and get the right way. I just pasted the code with that error. Overall I managed to bypass that error. It was a simple button format error that was making it redirect to index page. It's now solved Thanks.
  12. Hello, I've been having some troubles in form submitting with HTML and PHP dynamic pages. In this case, the link to register at my site is index.php?p=r Inside this link, I have a form where the user fills and then have a button to submit it: <form class="form-horizontal margin-none" id="registerform" method="_GET" autocomplete="on" action="index.php?p=r"> <!-- Widget --> <div class="widget widget-heading-simple widget-body-gray"> <div class="widget-body"> <h4>Personal Details</h4> <!-- Row --> <div class="row-fluid"> <!-- Column --> <div class="span6"> <!-- Group --> <div class="control-group"> <label class="control-label" for="firstname">First name</label> <div class="controls"><input class="span12" id="firstname" name="firstname" type="text" /></div> </div> <!-- // Group END --> <!-- Group --> <div class="control-group"> <label class="control-label" for="lastname">Last name</label> <div class="controls"><input class="span12" id="lastname" name="lastname" type="text" /></div> </div> <!-- // Group END --> <!-- Group --> <div class="control-group"> <label class="control-label" for="email">E-mail</label> <div class="controls"><input class="span12" id="email" name="email" type="email" /></div> </div> <!-- // Group END --> </div> <!-- // Column END --> <!-- Column --> <div class="span6"> <!-- Group --> <div class="control-group"> <label class="control-label" for="username">Username</label> <div class="controls"><input class="span12" id="username" name="username" type="text" /></div> </div> <!-- // Group END --> <!-- Group --> <div class="control-group"> <label class="control-label" for="password">Password</label> <div class="controls"><input class="span12" id="password" name="password" type="password" /></div> </div> <!-- // Group END --> <!-- Group --> <div class="control-group"> <label class="control-label" for="confirm_password">Confirm password</label> <div class="controls"><input class="span12" id="confirm_password" name="confirm_password" type="password" /></div> </div> <!-- // Group END --> </div> <!-- // Column END --> </div> <!-- // Row END --> <hr class="separator" /> <h4>Billing Details</h4> <!-- Row --> <!-- Alert --> <div class="alert alert-error"> <button type="button" class="close" data-dismiss="alert">x</button> <strong>Why we need your billing details?</strong> We need your billing details because as a seller/buyer, we need to know where to send the cards. So insert that data carefully, otherwhise can happen shipment mistakes. </div> <!-- // Alert END --> <div class="row-fluid"> <!-- Column --> <div class="span6"> <!-- Group --> <div class="control-group"> <label class="control-label" for="address">Address</label> <div class="controls"><input class="span12" id="address" name="address" type="text" /></div> </div> <!-- // Group END --> <!-- Group --> <div class="control-group"> <label class="control-label" for="zipcode">Zip Code</label> <div class="controls"><input class="span12" id="zipcode" name="zipcode" type="text" /></div> </div> <!-- // Group END --> <!-- Group --> <div class="control-group"> <label class="control-label" for="city">City</label> <div class="controls"><input class="span12" id="city" name="city" type="text" /></div> </div> <!-- // Group END --> </div> <!-- // Column END --> <!-- Column --> <div class="span6"> <!-- Group --> <div class="control-group"> <label class="control-label" for="State">State</label> <div class="controls"><input class="span12" id="state" name="state" type="text" /></div> </div> <!-- // Group END --> <!-- Group --> <div class="control-group"> <label class="control-label" for="confirm_password">Country</label> <div class="controls"><input class="span12" id="confirm_password" name="confirm_password" type="text" /></div> </div> <!-- // Group END --> </div> <!-- // Column END --> </div> <!-- // Row END --> <hr class="separator" /> <!-- Row --> <div class="row-fluid uniformjs"> <!-- Column --> <div class="span4"> <h4 style="margin-bottom: 10px;">Policy & Newsletter</h4> <label class="checkbox" for="agree"> <input type="checkbox" class="checkbox" id="agree" name="agree" /> I agree with <a href="#TOS" data-toggle="modal">Terms of Services</a> </label> <label class="checkbox" for="newsletter"> <input type="checkbox" class="checkbox" id="newsletter" name="newsletter" checked="true"/> Receive Newsletter </label> </div> <!-- // Column END --> </div> <!-- // Row END --> <hr class="separator" /> <!-- Form actions --> <div class="form-actions" align="right"> <button type="submit" class="btn btn-icon btn-primary glyphicons circle_ok"><i></i>Register</button> </div> <!-- // Form actions END --> </div> </div> <!-- // Widget END --> </form> <!-- // Form END --> The problems keeps in this part of code: <!-- Form actions --> <div class="form-actions" align="right"> <button type="submit" class="btn btn-icon btn-primary glyphicons circle_ok"><i></i>Register</button> </div> <!-- // Form actions END --> When I click the Register Button, it redirects me to index.php?username......password.... Instead of reloading in the same page (index.php?p=r&username=.... ) I would like too the browser link doesn't show that data ( username, password ). Already tried to change the method to POST but it doesn't work. Can anyone help me please?
  13. Hello, I'm developing a web based MMORPG with PHP and flash ( yep, text based games are the best =P ). I've implemented some flash for the battles ( simple things as my flash isn't pro, but it really works for what I want ) For some reasons, I want the player could "explore" the map. Doing this only with PHP would be an resource eater and my Flash Skills aren't so good to do mapping systems. So I would like to have an Ajax based map, where the player explore the maps ( yeah, serveral maps like plains, dungeons, lakes.. etc ). Imagine a Pokemon Game for example. The user plays around the field and when it is in specific points, then turn up a button where they can perform some actions that will call the flash ( for battles ) or php for any other options like find items, make quests etc. There's any best way to do it or anything that could help me in that mission? I would like to have this feature to make the game feature/media riched. Waiting for a reply where someone could help. Edit: For example, in this online game: http://static.monstermmorpg.com/images/Screenshots/EN/GamePage.png The left side we have the map ( the system I want to make ). When the user is over grass, it appears som action buttons in the center ( like battle and so one ). This could be better to you understand how I need to do it.
  14. After creating a simple php page the system seems now to being output the right info on all pages. That's weird but well, thanks anyway for your help
  15. That's the index page ( login page ). Then redirects for other page that welcomes the user ( always output "root" ). When acess de account information, it doesn't show information because the user (root) doesn't exists. In a simple file only with session_start and output it works well. It tells me the right logged in username. The problem is that I don't have anything else ( that's my PHP code on the pages that opens ) that could change the $_SESSION['user'] var. EDIT: After creating a simple php page the system seems now to being output the right info on all pages. That's weird but well, thanks anyway for your help
  16. I already noticed that and removed the session_start(); from both header.php and footer.php files. The index code where session is registered is: <?php if( $username != "" and $pw != ""){ $q="SELECT * from admutilizador where username='$username' and password='$pw'"; $result= mysql_query($q, $connection) or die ("Could not execute query : $q." . mysql_error()); if (mysql_num_rows($result) == 0) { echo "<div align=center><b>Invalid login details. Please try again.</b></div>"; } else { $r=mysql_fetch_array($result); session_start(); $_SESSION['user'] = $r['username']; $_SESSION['loggedin'] = true; Header("Location: main.php"); }}?> The files is in a PHP_SELF structure but that's the main code for register the session.
  17. Hello, After searching for some hours I don't get an answer for my question . I have a login index with session_start and register the user information with : $_SESSION['user'] = $r['username']; $_SESSION['loggedin'] = true; In that index file, it echo the right username that's logged in. On the other files, it echo always "root". My other files are combined with - Header.php ( Start of validation of session ) - Page.php ( Validate again ) - Footer.php ( End the validation of footer ) All files have a session start and if not logged in redirects to index file to login again. The problem, somewhere I have an error that I can't discover.. Could you please help me ? Header.php <?php session_start(); include("connect.php"); include("../inc/config.php"); if( isset($_SESSION['user']) and $_SESSION['loggedin'] == true){ ?> MY OWN CODE <?php } else{ Header("Location:index.php"); } ?> PAGE.PHP <?php session_start(); if( isset($_SESSION['user']) and $_SESSION['loggedin'] == true){ ?> <?php include("header.php"); $session = session_decode(session_id()); $result = mysql_query("SELECT * FROM admutilizador WHERE id='$session'") or die(mysql_error()); $row = mysql_fetch_array($result); ?> MY OWN CODE <?php include("footer.php"); ?> <?php } else{ Header("Location:index.php"); } FOOTER.PHP <?php session_start(); if( isset($_SESSION['user']) and $_SESSION['loggedin'] == true){ ?> MY OWN CODE <?php } else{ Header("Location:index.php"); } Can someone help me ? thanks in advance. P.S. I used a test session var $_SESSION['test'] = "TEST"; and it keeps the records in other pages. Using the $_SESSION['user'] = $r['username']; ( info from DB that returns the right username in the same page, echoing it in other pages always output root. Hope this test could help anyone too.
  18. No, there's no line breaks. I'ts a simple function that return a number from the DB. In this case, adfly API tool javascript code.. It have a ID you have to use, but another user have another ID. That ID is defined in the DB instead of edit it manually. Any ideas?
  19. After reading some threads around the net I can't find a situable solutions for this. In my script I want to use a javascript code ( external source from another website ) and there's a JS variable with an ID ( the user ID in the other website). In my script I have the ID stored in the DB and I want to insert it in the javascript by the ID listed in the DB ( that can be changed, so there's the PHP needed ) The JS code: <script> var siteID = 11111; all rest of code </script> How can I change the value of siteID in JS for the one I want? Lets say I would like something like: var siteID = <?php GetOtherSiteID(); ?>; This seems no to be possible. There's any sugestion?
  20. As I can't edit the thread, here is the code: index.php page ( dynamic links ) $page = (isset($_GET['p']) === TRUE? strtolower($_GET['p']) : ''); switch($page){ case 'music': include("pages/music.php"); break; default: include("pages/main.php"); break; } header.php ( Multi Language) session_start(); header('Cache-control: private'); // IE 6 FIX if(isSet($_GET['lang'])) { $lang = $_GET['lang']; // register the session and set the cookie $_SESSION['lang'] = $lang; setcookie('lang', $lang, time() + (3600 * 24 * 30)); } else if(isSet($_SESSION['lang'])) { $lang = $_SESSION['lang']; } else if(isSet($_COOKIE['lang'])) { $lang = $_COOKIE['lang']; } else { $lang = 'en'; } switch ($lang) { case 'en': $lang_file = 'lang.en.php'; break; case 'pt': $lang_file = 'lang.pt.php'; break; default: $lang_file = 'lang.en.php'; } include_once 'languages/'.$lang_file; Example Links ( Langue Choose: ) <a href="index.php?p=<?php echo $_GET['p']; ?>&lang=uk"><img src="images/uk.png" /></a> <a href="index.php?p=<?php echo $_GET['p']; ?>&lang=pt"><img src="images/pt.png" /> </a> Example Links ( Page Choose: ) <li><a href="index.php?p=main&lang=<?php echo $_GET['lang']; ?>"><?php echo $lang['MENU_HOME'];?></a></li> <li><a href="index.php?p=music&lang=<?php echo $_GET['lang']; ?>"><?php echo $lang['MENU_MUSIC'];?></a></li> Hope this can help
  21. Hello, At my free time I just want to play with PHP and I'm trying to assume a website with dynamic links and multi language at the same time. I use $_GET to get the language and the page that user wants to load, but I have some problems. The first run doesn't work. After define the language and page it works perfectly. If you could, please see the code I used in the files attached Multi-Language - header.php - Between ln4 and 43. The example links lines 74,75,83,84 Dynamic Links - index.php - Between line 5 and 17 Could you please help me in this way? Thanks in advance. [attachment deleted by admin]
  22. Hi, I'm almost new to php and I would like to improve my image resizer script. If possible, I would like you to help me to do the follow 2 things: 1. Print a message if the image extension isn't JPG or JPEG; 2. Print a message if the fieds uploadfile,width or height was left blank; This is my code: <?php // This is the temporary file created by PHP $uploadedfile = $_FILES['uploadfile']['tmp_name']; $newwidth= $_POST['width']; $newheight= $_POST['height']; //Get File $file = $_FILES['uploadfile']; // Create an Image from it so we can do the resize $src = imagecreatefromjpeg($uploadedfile); // Capture the original size of the uploaded image list($width,$height)=getimagesize($uploadedfile); // This will get the pixels entered by user $tmp=imagecreatetruecolor($newwidth,$newheight); // this line actually does the image resizing, copying from the original // image into the $tmp image imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height); // now write the resized image to disk. I have assumed that you want the // resized, uploaded image file to reside in the ./images subdirectory. $filename = "img/". $_FILES['uploadfile']['name']; imagejpeg($tmp,$filename,100); echo "<center>Resized image to \"$newwidth\"x\"$newheight\"</center>\n"; echo "<center><img src=\"$filename\" border='0'></center>\n"; imagedestroy($src); imagedestroy($tmp); // NOTE: PHP will clean up the temp file it created when the request // has completed. ?> So, someone could help me?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.