Jump to content

Search the Community

Showing results for tags 'php'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. Hi, I have a database that has the following layout (only relevant colums detailed index season day month year goals_scored I want to create an array with a running total of goals scored by a quarter. For example, Sum of goals scored between month=8 to month=10 month=11 to month=1 month=2 to month=4 month=5 to month=7 Where year=2002 then go through years 2002-current year what ever it is and it up. So if I have sum of month=8-10: 0 sum of month=11-1: 2 sum of month=2-4: 8 sum of month=5-7: 5 When I echo the array it will be in this format: (0,2,10,15) I also want to make a separate query for a single year, by month, i.e sum of goals scored where month=7, month=8 etc. Any indication and help explaining the function for this would help. My php is very basic, I know how create a query and make loop to echo a table of results etc. These arrays are for graphs. I want the graph to be ready for the full season even if its not happened yet.
  2. Hi I'm trying to recall a column from my table and insert it into an array. and then use the array and devide it into batches. Here is the code I got so far. $query = "SELECT * FROM broadcast"; $result1 = mysql_query($query) or die(mysql_error()); $users = array(); while($row = mysql_fetch_array($result1)){ $users[] = $row['onorof']; } $batchSize = 50; // set size of your batches $batches = array_chunk($users, $batchSize); require_once ('MxitAPI.php'); /* Instantiate the Mxit API */ $key = '50709335604c4feeaf9009b6e5f024a1'; $secret = '45a7b65b216d4f638a3cf4fc4f4e802f'; $app = 'guniverse'; $nick = urldecode($_SERVER['HTTP_X_MXIT_NICK']); if(!isset($nick)) { $nick = "Debater"; } $message = $_POST["message"]; $message1 = "*" . $nick . "*" . ": " . $message; $api = new MxitAPI($key, $secret); $api->get_app_token('message/send'); foreach ($batches as $batch) { $list = join(',', $batch); // process the batch list here $api->send_message($app, $batches, $message1, 'true'); }
  3. Anyone know why my preg_match is being triggered by this term: 3D Hobby Shop To me it should allow letters and numbers etc. My php: if(preg_match('/[^a-z0-9\-\_\,\!\?\+\ \.]+/i',$_POST['title'])) { $err[]='<p class="error" style="color: #ed1c24;">Your Title contains invalid characters!</p>'; }
  4. I have a very troubling problem at hand. I am using a web-socket server that runs in PHP. The issue is I need to be able to use a setInterval/setTimeout function similar to javascript, but within my php server. I do not have the time or resources to convert my entire project over to nodejs/javascript. It will take forever. I love php so much, that I do not want to make the switch. Everything else works fine and I feel like it's not worth it to re-write everything just because I cannot use a similar setInterval function inside php. Since the php socket server runs through the shell, I can use a setInterval type function using a loop: protected function on_server_tick($counter) { if($counter%5 == 0) { // 5 seconds interval } if($counter%10 == 0) { // 10 seconds interval } } $this->last_tick_time = microtime(true); $this->tick_interval = 1; $this->tick_counter = 0; while(true) { //loop code here... $t= microtime(true) - $this->last_tick_time; if($t>= $this->tick_interval) { $this->on_server_tick(++$this->tick_counter); $this->last_tick_time = microtime(true) - ($t- $this->tick_interval); } } This code does work as intended, but it seems a bit overboard for resources and I feel like that while loop will suck a lot resources. Is there anyway I can re-compile PHP from source and include a "while2" loop that only iterates every 500 miliseconds instead of instantly?
  5. First off, I hope I explain this right. I am wanting to show fields if only the checkbox next to it is checked. I have it set up that the fields will not show if the variable is empty, but I would like for it not to show unless the checkbox is checked if there is a variable. Here is an image of what is in the admin Here is the code I have for the variable to be shown on the site <?php if (isset($manufacture) && !empty($manufacture)) : ?> <li class="element element-text"> <strong>Manufacture: </strong> <?php echo $manufacture;?> </li> <?php endif; ?> <?php if (isset($model) && !empty($model)) : ?> <li class="element element-text"> <strong>Model #: </strong> <?php echo $model;?> </li> <?php endif; ?> And here is the code I am using when I put the item in the admin section <div class="form-group"> <label class="col-md-3">Manufacture</label> <div class="col-md-8"> <input type="text" name="manufacture" value="" class="form-control" /> </div> <!-- /.col --> <input type="checkbox" name="manufactureCheck"><span style="float:right; font-size: 10px; margin-top: 4px">Check to show</span> </div> <!-- /.form-group --> <div class="form-group"> <label class="col-md-3">Model</label> <div class="col-md-8"> <input type="text" name="model" value="" class="form-control" /> </div> <!-- /.col --> <input type="checkbox" name="modelCheck"> </div> <!-- /.form-group --> Also, I know I will have to add if the box is checked to the database. Could I just use one row named "Checked"? As for the code to make it show, couldn't I use something like this? <?php if ( isset($manufacture) && !empty($manufacture) ​&& !isset($manufactureCheck) ​&& !empty($manufactureCheck)) : ?> <li class="element element-text"> <strong>Manufacture: </strong> <?php echo $manufacture;?> </li> <?php endif; ?> Sorry if I didn't explain this good enough, I am very new to php.
  6. Please see attached my bank account class files. The key guidance I need is how to instantiate a class from another class. For example, you can see in Customer.class.php, I instantiate a new Account, but am not sure how i pass in the balance and account number to Customer in order that they can instantiate the Account? This is the same as Account instantiate a BankCard object. I am a little confused - any help appreciated. BankAccountApp.zip
  7. I need Help!!! I have an assignment due for a 'Guess the State Capital' Game, the details are here http://www.cs.wcupa.edu/rkline/wpeval/program-2.html. I can't get the answer to generate at all! I have no idea what I'm doing. Everything I've got so far is uploaded below. program.php
  8. hello, i have this function, function withdraw() { global $db,$ir,$c,$userid; if($_POST['amount'] > $ir['bankmoney']) { echo '<span style="color:red;">You dont have enough money saved to withdraw that much!</span>'; } else { $db->query("UPDATE `users` SET `bankmoney` = `bankmoney` - ".$_POST['amount'] .", `money` = `money` + " . $_POST['amount'] . " WHERE `userid` = ".$userid); $ir['money'] += $_POST['amount']; echo 'You withdrew ' . money_formatter($_POST['amount'] + 0) . ' into your hand from your account.<br/> You know have ' . money_formatter($ir['money'] + 0) . ' in your hand.'; } } that does not seem to work correctly it will not seem to move past the first if statement even if the amount is less then the bank mone. the form which submits this is <a href="test.php?withdraw" target="_blank">>Withdraw</a><br/>'; if (isset($_GET['withdraw'])== 1){ echo' <div id="withdraw" style="background: #ffffd3;border: 1px #ffff99 solid;padding: 20px;width: 250px;margin: 5px;"> <form action="" method="post" onsubmit="makeTrans(\'withdraw\');return false;"><input type="text" name="withdraw" value="'.($ir['bankmoney']).'" /> <input type="submit" value="Withdraw" /></form> <div id="withdraw_callback"> Please select the amount you wish to withdraw then hit the withdraw button next to it. </div> </div> '; thanks
  9. Hey All, I am new to php and I am trying to learn how to set up my admin where it checks to see if the user is logged in before they can access the rest of the admin page. Right now I have it working but the user can access the pages if they know the url. I tried following a tutorial I found online but all it is doing is redirecting me back to the login page. It does the checklogin.php and it goes to the dashboard.php but redirects me as soon as I get there. Can you please look at my code and let me know if I am missing something simple? Any help would be very much appreciated. My form <form name="form1" method="post" action="checklogin.php"> <div id="wrappermiddle"> <h2>Login</h2> <div id="username_input"> <div id="username_inputleft"></div> <div id="username_inputmiddle"> <input name="myemail" type="text" id="myusername" placeholder="Email Address"> <img id="url_user" src="./images/mailicon.png" alt=""> </div><!--ends username_inputmiddle--> <div id="username_inputright"></div> </div><!--ends username_input--> <div id="password_input"> <div id="password_inputleft"></div> <div id="password_inputmiddle"> <input name="mypassword" type="password" id="mypassword" placeholder="Password"> <img id="url_password" src="./images/passicon.png" alt=""> </div><!--ends password_inputmiddle--> <div id="password_inputright"></div> </div><!--ends password_input--> <div id="submit"> <input type="image" src="./images/submit.png" name="Submit" value="Login"> </form> checklogin.php <?php $host="localhost"; // Host name $username="db-username"; // Mysql username $password="db-password"; // Mysql password $db_name="db-name"; // Database name $tbl_name="members"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // username and password sent from form $myemail = ""; $mypassword = ""; $errorMessage = ""; $num_rows = 0; $myemail=$_POST['myemail']; $mypassword=$_POST['mypassword']; // To protect MySQL injection (more detail about MySQL injection) $myemail = stripslashes($myemail); $mypassword = stripslashes($mypassword); $myemail = mysql_real_escape_string($myemail); $mypassword = mysql_real_escape_string($mypassword); $sql="SELECT * FROM $tbl_name WHERE myemail='$email' and password='$mypassword'"; $result=mysql_query($sql); if ($result) { } else { $errorMessage = "Error logging on"; } // Mysql_num_row is counting table row $num_rows = mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if ($num_rows > 0) { $errorMessage= "logged on "; } else { $errorMessage= "Invalid Logon"; } // Register $myusername, $mypassword and redirect to file "login_success.php" if ($num_rows > 0) { session_start(); $_SESSION['members'] = "1"; header ("Location: dashboard.php"); } ?> Here is what I have at the top of dashboard.php <?PHP session_start(); if (!(isset($_SESSION['checklogin']) && $_SESSION['checklogin'] != '')) { header ("Location: index.php"); } ?> Also, so I don't have to ask again, I have my database set up that a user can be a superuser (role 1) or a regular user (role 2). How can I set it that based on what type of user they are, they get sent to 2 different urls? I have learned so much from this site along with other forums but this one I haven't been able to figure out. Like I mentioned, I seen and followed a few tutorials but I couldn't get them working with my code I already had. So I figured this would be easier than having to redo my entire login page. Thanks Again.
  10. Need Help!!! I am trying to build an application in php without database connectivity. I have a index page where i have 6 users. 1 among the 6 users will act as admin. I am using array to get the username & password When the users logs in, some of the options should be disabled or non-editable. Assume "raj" plays the admin role Code what i have: <?php session_start(); /* Starts the session */ /* Check Login form submitted */ if(isset($_POST['Submit'])){ /* Define username and associated password array */ $logins = array('raj' => 'raj123@123','ram' => 'ram@123','dev' => 'dev@123','dave' => 'dave@123','Sugi' => 'sugi@123','raki' => 'raki@123','sam' => 'sam@123'); /* Check and assign submitted Username and Password to new variable */ $Username = isset($_POST['Username']) ? $_POST['Username'] : ''; $Password = isset($_POST['Password']) ? $_POST['Password'] : ''; /* Check Username and Password existence in defined array */ if (isset($logins[$Username]) && $logins[$Username] == $Password){ /* Success: Set session variables and redirect to Protected page */ $_SESSION['UserData']['Username']=$logins[$Username]; header("location:signin.php"); exit; } else { /*Unsuccessful attempt: Set error message */ $msg="<span style='color:red'>Invalid Login Details</span>"; } } ?> Any help on this will be much appreciated!!!! Thanks
  11. Hi all, I am working on a search script which searches article titles from the table. i have worked out the function, but have not been able to add an error message if the results are zero. my class file has this following function public function search($table){ $search=$_GET['search']; if ($this->databaseConnection()) { $sql="SELECT * FROM $table WHERE title LIKE '%$search%'"; $q = $this->db_connection->query($sql) or die("failed!"); while($r = $q->fetch(PDO::FETCH_ASSOC)){ $data[]=$r; } return $data; } } my results page has the following code <?php foreach($crud->search("articles") as $value){ extract($value); echo <<<show <p>" <a href="view.php?article_id=$article_id">$title</a> "</p> <br> show; } ?> would be highly obliged if anyone can help me out. apologies if this is a stupid question, but i am pretty much an amateur still. regards, Nayan
  12. So here's the situation. 1. I retrive records form mysql database. WORKS. 2. Within each record, I load a "form" via on click .button. WORKS. 3. The form is basically a way for a User to send a message to that record specifically. WORKS That process works. What doesn't work is that every time I submit a form to the database, it will not insert the "message" field text(appears empty) and the "record_id" will insert but it'll be same for all records inserted, no matter how many different records forms I submit. Other data like "message-to" and "message-by" insert fine. Here is the full page setup. Also, session_start(); is in the init.php <?php require_once 'core/init.php'; $user = new User(); $mainUserid = escape($user->data()->user_id); ?> <!DOCTYPE HTML> <html lang="en"> <head> <meta charset="UTF-8"> <title><?php echo $title; ?></title> <meta name="description" content="<?php echo $description; ?>"> <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"> <link rel="stylesheet" href="css/style.css" media="screen"> </head> <body> $getRecord = $db->prepare("SELECT records.*, users.* FROM records LEFT JOIN users ON records.user_id = users.user_id ORDER BY record_id DESC LIMIT 10"); $getRecord->execute(); $resultRecord = $getRecord->fetchAll(PDO::FETCH_ASSOC); if(count($resultRecord) < 1) { $error = '0 records found.'; } else { foreach($resultRecord as $row) { $record_id = escape(intval($row['record_id'])); $user_id = escape(intval($row['user_id'])); $username = escape($row['full_name']); $title = escape($row['title']); $details = escape($row['details']); $_SESSION['record-id'] = $record_id; $_SESSION['message-to'] = $user_id; $_SESSION['message-by'] = $mainUserid; $message = Input::get('message'); // HTTP method POST or GET $_SESSION['message'] = $message; ?> <div class="record"> <h1><?php echo $title; ?></h1> <p><?php echo $details; ?></p> <p><?php echo $user_id; ?></p> <button class="button">send message</button> <!-- this form loads through on click(.button) function and is located in "ajax/form.php" --> <form class="new-form"> <textarea name="message" class="message">Enter message</textarea> <input type="button" name="submit" class="form-submit" value="Send Message"> </form> </div> <?php } } <!-- js scripts below --> <script src="js/jquery-1.11.0.min.js"></script> <script> $(document).ready(function(){ $(".button").click(function(){ $(this).parent().load("ajax/form.php"); }); }); </script> <script> $(document).on('click','.form-submit',function() { if($(".message").val()==='') { alert("Please write a message."); return false; } $(".form-submit").hide(); //hide submit button var myData = 'message='+ $(".message").val(); //build a post data structure jQuery.ajax({ type: "POST", // HTTP method POST or GET url: "process.php", //Where to make Ajax calls dataType:"text", // Data type, HTML, json etc. data:myData, //Form variables success:function(response){ $(".message").val(''); //empty text field on successful $(".form-submit").show(); //show submit button }, error:function (xhr, ajaxOptions, thrownError){ $(".form-submit").show(); //show submit button alert(thrownError); } }); }); </script> </body> </html> here is process.php <?php require_once 'core/init.php'; $session_record_id = $_SESSION['record-id']; $session_message_to = $_SESSION['message-to']; $session_message_by = $_SESSION['message-by']; $session_message = $_SESSION['message']; $insertMssg = $db->prepare("INSERT INTO sub_records(record_id, message_to, message_by, message, bid_posted) VALUES(:record_id, :message_to, :message_by, :message)"); $insertMssg->bindParam(':record_id', $session_record_id); $insertMssg->bindParam(':message_to', $session_message_to); $insertMssg->bindParam(':message_by', $session_message_by); $insertMssg->bindParam(':message', $session_message); $resultInsert = $insertMssg->execute(); if($resultInsert == false) { $error = 'Your message could not be inserted.'; } else { $success = 'Your message has been added.'; } ?> <div class="success"><?php echo $success; ?></div> <div class="error"><?php echo $error; ?></div>
  13. Hi I've created a scricpt thats devided into 4 parts Part 1 Inserting info into a text file Part 2 Removing info from the text file Part 3 Lookup the value stored within the text file if it match show form if not don't show form Part 4 Broadcasting the message I'm currently experiencing a problem with Part 2. Every time I click the button it doesn't remove the info needed after a few clicks the whole unique.csv file gets removed <html> <head> </head> <body> Welcome To The Chat! To enter please Click <a href=\?func=yes>HERE</a> To exit please Click <a href=\?func=no>HERE</a> <? //Part 1 if($_GET['func']=='yes') { $myfile = fopen("users.csv", "a+") or die("Unable to open file!"); $mxituid = $_SERVER["HTTP_X_MXIT_USERID_R"]; if(!isset($mxituid)) { $mxituid = "Debater"; } $txt = "$mxituid\n"; fwrite($myfile, $txt); fclose($myfile); $list = file('users.csv'); $list = array_unique($list); file_put_contents('unique.csv', implode('', $list)); header("Location: index.php"); exit; } //Part 2 if($_GET['func']=='no') { $mxituid = $_SERVER["HTTP_X_MXIT_USERID_R"]; $source = "unique.csv"; $raw = file_get_contents($source) or die("Cannot read file"); $wordlist = $mxituid; $raw = preg_replace($wordlist, "", $raw); file_put_contents($source, $raw); header("Location: index.php"); exit; } //Part 3 $mxituid = $_SERVER["HTTP_X_MXIT_USERID_R"]; $file = 'unique.csv'; $searchfor = $mxituid; // get the file contents, assuming the file to be readable (and exist) $contents = file_get_contents($file); // escape special characters in the query $pattern = preg_quote($searchfor, '/'); // finalise the regular expression, matching the whole line $pattern = "/^.*$pattern.*\$/m"; // search, and store all matching occurences in $matches if(preg_match_all($pattern, $contents, $matches)){ print "Type in your message<br>"; print <<<HERE <form method="post" action="index.php"> <input type = "text" name = "message" value = ""> <input type="submit" value="Guess"> </form> HERE; } else{ echo "You should Enter Chat first!"; } //Part 4 $visitor = 'unique.csv'; $f_pointer=fopen($visitor,"r"); // file pointer $users = array(); while ($ar=fgetcsv($f_pointer)) { if ($ar[0] != '') $users[] = $ar[0]; //only store line in new array if it contains something } fclose ($f_pointer); $batchSize = 50; // set size of your batches $batches = array_chunk($users, $batchSize); require_once ('MxitAPI.php'); /* Instantiate the Mxit API */ $key = '50709335604c4feeaf9009b6e5f0424a1'; $secret = '45a7b65b216d4f638a3cf4fc84f4e802f'; $app = 'guniver3se'; $message = $_GET["message"]; $api = new MxitAPI($key, $secret); $api->get_app_token('message/send'); foreach ($batches as $batch) { $list = join(',', $batch); // process the batch list here $api->send_message($app, $list, $message, 'true'); } echo 'Success<br>'; ?> </body> </html>
  14. Hi, I am struggling to get a htmnl 5 canavas not to work after the back button is pressed in the browser. I have stopped back button being allowed but it stops me using javascript to use go back which i need. The code is as follows. <?php require('globals.php'); if ($ir['wof_spins'] > 0) { error("You have span the wheel this hour"); //this does not work on page back } ?> <!DOCTYPE html> <html> <head><meta http-equiv="Content-Type" content="text/html; charset=euc-kr"> <script type='text/javascript' src='http://code.jquery.com/jquery-compat-git.js'></script> <script type='text/javascript' src="js/jquery.transit.min.js"></script> <style type='text/css'> .wheel-wrap { position: relative; width: 550px; height: 550px; overflow: hidden; margin: 0 auto; z-index: 1; } .marker { top: 10px; left: 247px; z-index: 1; position: absolute; } .wheel { top: 90px; left: 74px; width: 550px; z-index: 1; } </style> <script type='text/javascript'>//<![CDATA[ $(function(){ window.WHEELOFFORTUNE = { cache: {}, init: function () { console.log('controller init...'); var _this = this; this.cache.wheel = $('.wheel'); this.cache.wheelMarker = $('.marker'); this.cache.wheelSpinBtn = $('.wheel'); //mapping is backwards as wheel spins clockwise //1=win this.cache.wheelMapping = [400, 120, 80, 750, 150, 300, 60, 175, 500, 125, 75, 1000, 120, 200, 90, 600, 100, 250].reverse(); this.cache.wheelSpinBtn.on('click touchstart', function (e) { e.preventDefault(); if (!$(this).hasClass('disabled')) _this.spin(); }); //reset wheel this.resetSpin(); //setup prize events this.prizeEvents(); }, spin: function () { console.log('spinning wheel'); var _this = this; // reset wheel this.resetSpin(); //disable spin button while in progress this.cache.wheelSpinBtn.addClass('disabled'); /* Wheel has 10 sections. Each section is 360/10 = 36deg. */ var deg = 1500 + Math.round(Math.random() * 1500), duration = 6000; //optimal 6 secs _this.cache.wheelPos = deg; //transition queuing //ff bug with easeOutBack this.cache.wheel.transition({ rotate: '0deg' }, 0) .transition({ rotate: deg + 'deg' }, duration, 'easeOutCubic'); //move marker _this.cache.wheelMarker.transition({ rotate: '-20deg' }, 0, 'snap'); //just before wheel finish setTimeout(function () { //reset marker _this.cache.wheelMarker.transition({ rotate: '0deg' }, 300, 'easeOutQuad'); }, duration - 500); //wheel finish setTimeout(function () { // did it win??!?!?! var spin = _this.cache.wheelPos, degrees = spin % 360, percent = (degrees / 360) * 100, segment = Math.ceil((percent / 6)), //divided by number of segments win = _this.cache.wheelMapping[segment - 1]; //zero based array console.log('spin = ' + spin); console.log('degrees = ' + degrees); console.log('percent = ' + percent); console.log('segment = ' + segment); console.log('win = ' + win); //display dialog with slight delay to realise win or not. setTimeout(function () { $.ajax({ url: 'spinwheel.php', type: 'post', data: {"win":win}, success: function(data) { if(!alert('You have won 짜'+win)) document.location = 'http://samuraiassault.com/loggedin.php'; } }); }, 700); //re-enable wheel spin _this.cache.wheelSpinBtn.removeClass('disabled'); }, duration); }, resetSpin: function () { this.cache.wheel.transition({ rotate: '0deg' }, 0); this.cache.wheelPos = 0; } } window.WHEELOFFORTUNE.init(); });//]]> </script> </head> <body> <!-- By http://jquery4u.com / Sam Deering --> <h3><u>Wheel Of Fortune</u></h3><hr/> <table><tr> <td class="contentcontent" width="100%"> <div class="wheel-wrap"> <img class="wheel" src="images/wheel.jpg" /> <img class="marker" src="images/marker.png" /> </div> </tr> </td> </table><hr/><?php echo $goback; ?><hr/> </body> </html> thanks for you help in advance
  15. Hello. I have a problem when I send an article to DB from the server (in localhost everything is working fine). So, the news_post (textarea) is sending backslashes before single and double quotes, broking embed elements (images, videos, etc.). The articles are sent to DB throught this coide:
  16. For eg, say I am retreiving 3 records from database and they look like this. <div class="record"> <h1>Record title 1</h1> <p>Record description</p> <button class="button">send message</button> </div> <div class="record"> <h1>Record title 2</h1> <p>Record description</p> <button class="button">send message</button> </div> <div class="record"> <h1>Record title 3</h1> <p>Record description</p> <button class="button">send message</button> </div> and this is my ajax to load the form. <script> $(document).ready(function(){ $(".button").click(function(){ $(".record").load("form.php .new-form"); }); }); </script> the form looks like this. <form class="new-form"> <textarea name="message" class="message"></textarea> <input type="button" name="submit" class="form-submit" value="Send Message"> </form> That all works. The only problem with that is, it loads the form in EACH record. How can I make it so that the form only loads to the div record from which I am calling from?
  17. I'm writing a small applications with episodes which contain 10-15 screenshots with each screenshot having 5 different resolutions. Every week there are about 20 new episodes. You can imagine that every week I have a lot of screenshots which have to be somehow linked to their respective episode. Currently the filenames are stored in a MySQL database, but after 5 minutes of testing I already have 100+ rows. Not quite sure if that's a smart way of moving forward. The advantage of having them in the DB is that I can easily grab them using Eloquent ORM without having to finnick around with regeneration of filenames for on the fly loading. Are there any good other alternatives of linking multiple files to database entries? Or should I just stick with the current method? What would be some adverse effects of doing it this way?
  18. I'm just learning php and I have a web scraper I'm working on using Simple HTML DOM. It's almost complete but still lacks a bit of logic. What I want the script to do is scrape multiple pages and compare the links, and IF a matching domain is found linked from more than 1 page, send an email What I've come up works for matching a domain that's hard coded into the script, but I want to match domains from other pages. And, the script will send an email for every match it finds but I just want 1 email with all the matching domains. I believe array_intersect() is the function I need to be working with but I can't figure this out. I will be so happy if I can get this completed. Thanks for your time and consideration. Here is my code // Pull in PHP Simple HTML DOM Parser include("simple_html_dom.php"); $sitesToCheck = array( array("url" => "http://www.google.com"), array("url" => "http://www.yahoo.com"), array("url" => "http://www.facebook.com") ); // For every page to check... foreach($sitesToCheck as $site) { $url = $site["url"]; // Get the URL's current page content $html = file_get_html($url); // Find all links foreach($html->find('a') as $element) { $href = $element->href; $link = $href; $pattern = '/\w+\..{2,3}(?:\..{2,3})?(?:$|(?=\/))/i'; $domain = $link; if (preg_match($pattern, $domain, $matches) === 1) { $domain = $matches[0]; } // This works for matching google.com // but I want to match with $domain from other sites if (preg_match("/google.com/", $domain)) { mail("someone@example.com","Match found",$domain); } else { echo "A match was not found." . "<br />"; } } }
  19. Need little help with the quiz problem. I want to set time limit for each question in quiz module (say 30 seconds) and after that time, the form will auto submit the question (auto submit = no option selected = unanswered). There are 3 questions, so total time limit is 90 sec (30 sec each). I'm doing this via XAMPP. The link below provide the work so far https://www.dropbox.com/s/4dzlgjtjzvs48vw/quiz.rar?dl=0 Thanks
  20. Hey guys I am new to CSRF attacks and would like to know a little more about it. So I was messing with my code and here is what happened There is 2 pages, demo.php and edit_account.php demo.php and edit_account.php have the same exact form but the demo.php forms action value is edit_account.php. edit_account.php is where the database and everything gets updated. So when I submited the form on demo.php it went to edit_account.php and updated the database and everything because they have the same form names etc. So is this considered a CSRF attack and does this mean I need to put a "token" or whatever they do to protect from these attacks on EVERY form; because some hacker can just make a fake website, copy the form from inspect element and put it on their website and be updating the data on another website without even them knowing. Example form code that I tested and this attacked worked. <form action="edit_account.php" method="POST"> <br><br><table style="width:60%"> <tr> <td><font style="font-size:22px;font-weight:bold;">Birthday:</font></td> <td> <label class="a"><select name="birth_day"><option value='0'>Day</option><option value="1">1</option> <option value="2" selected>2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">20</option> <option value="21">21</option> <option value="22">22</option> <option value="23">23</option> <option value="24">24</option> <option value="25">25</option> <option value="26">26</option> <option value="27">27</option> <option value="28">28</option> <option value="29">29</option> <option value="30">30</option> <option value="31">31</option> </select></label><label class='a'><select name='birth_month'><option value="1">Month</option> <option value="2">January</option> <option value="3">February</option> <option value="4">March</option> <option value="5">April</option> <option value="6">May</option> <option value="7">June</option> <option value="8">July</option> <option value="9">August</option> <option selected="selected" value="10">September</option> <option value="11">October</option> <option value="12">November</option> </select></label><label class='a'><select name='birth_year'> <option value='private'>Year</option><option value="1900">1900</option> <option value="1901">1901</option> <option value="1902">1902</option> <option value="1903">1903</option> <option value="1904">1904</option> <option value="1905">1905</option> <option value="1906">1906</option> <option value="1907">1907</option> <option value="1908">1908</option> <option value="1909">1909</option> <option value="1910">1910</option> <option value="1911">1911</option> <option value="1912">1912</option> <option value="1913">1913</option> <option value="1914">1914</option> <option value="1915">1915</option> <option value="1916">1916</option> <option value="1917">1917</option> <option value="1918">1918</option> <option value="1919">1919</option> <option value="1920">1920</option> <option value="1921">1921</option> <option value="1922">1922</option> <option value="1923">1923</option> <option value="1924">1924</option> <option value="1925">1925</option> <option value="1926">1926</option> <option value="1927">1927</option> <option value="1928">1928</option> <option value="1929">1929</option> <option value="1930">1930</option> <option value="1931">1931</option> <option value="1932">1932</option> <option value="1933">1933</option> <option value="1934">1934</option> <option value="1935">1935</option> <option value="1936">1936</option> <option value="1937">1937</option> <option value="1938">1938</option> <option value="1939">1939</option> <option value="1940">1940</option> <option value="1941">1941</option> <option value="1942">1942</option> <option value="1943">1943</option> <option value="1944">1944</option> <option value="1945">1945</option> <option value="1946">1946</option> <option value="1947">1947</option> <option value="1948">1948</option> <option value="1949">1949</option> <option value="1950">1950</option> <option value="1951">1951</option> <option value="1952">1952</option> <option value="1953">1953</option> <option value="1954" selected>1954</option> <option value="1955">1955</option> <option value="1956">1956</option> <option value="1957">1957</option> <option value="1958">1958</option> <option value="1959">1959</option> <option value="1960">1960</option> <option value="1961">1961</option> <option value="1962">1962</option> <option value="1963">1963</option> <option value="1964">1964</option> <option value="1965">1965</option> <option value="1966">1966</option> <option value="1967">1967</option> <option value="1968">1968</option> <option value="1969">1969</option> <option value="1970">1970</option> <option value="1971">1971</option> <option value="1972">1972</option> <option value="1973">1973</option> <option value="1974">1974</option> <option value="1975">1975</option> <option value="1976">1976</option> <option value="1977">1977</option> <option value="1978">1978</option> <option value="1979">1979</option> <option value="1980">1980</option> <option value="1981">1981</option> <option value="1982">1982</option> <option value="1983">1983</option> <option value="1984">1984</option> <option value="1985">1985</option> <option value="1986">1986</option> <option value="1987">1987</option> <option value="1988">1988</option> <option value="1989">1989</option> <option value="1990">1990</option> <option value="1991">1991</option> <option value="1992">1992</option> <option value="1993">1993</option> <option value="1994">1994</option> <option value="1995">1995</option> <option value="1996">1996</option> <option value="1997">1997</option> <option value="1998">1998</option> <option value="1999">1999</option> <option value="2000">2000</option> <option value="2001">2001</option> <option value="2002">2002</option> <option value="2003">2003</option> <option value="2004">2004</option> <option value="2005">2005</option> <option value="2006">2006</option> <option value="2007">2007</option> <option value="2008">2008</option> <option value="2009">2009</option> <option value="2010">2010</option> <option value="2011">2011</option> <option value="2012">2012</option> <option value="2013">2013</option> <option value="2014">2014</option> <option value="2015">2015</option> </select></label> <br><br>
  21. <?php $file = "C:\folder\log.txt"; // file() (PHP 3, PHP 4, PHP 5) // read the file into array $ar_log = file($file); // flip the array $ar_log = array_reverse($ar_log); // convert array to string $log = implode('',$ar_log); // print result echo '<pre>'.$log.'</pre>'; ?> I have this bit of code that outputs some logs from a txt file in descending order for me. This works absolutely awesome and does the trick. However, i am trying to replace some text wich is in that .txt so that it changes on the output of the website. The text i am trying to replace is Arma-AH.net to DayZNorway.com Now i have fiddled around with str_replace but i simply cannot get it to work. I am not good at this so i desperately need some assistance. I also would have loved to be able to filter out quotation marks and place it all in tables with text explaining what each table includes. Such as Playername, Killed, weapon, and so on.. You get the jist. Preferrably on a black background with a colored text if doable.. Then i have this second script. <?php $file = 'C:\wamp\www\Killboard\EPChernarus1\PhitLog.txt'; $searchfor = 'Chernarus'; header('Content-Type: text/html'); $contents = file_get_contents($file); $contents = str_replace("(ArmA-AH.net)", "(DayZNorway.com)", $contents); $pattern = preg_quote($searchfor, '/'); $contents = str_replace("DayZ Instance: 11", " Map: Chernarus ", $contents); $pattern = "/^.*$pattern.*$/m"; $contents = str_replace("PKILL", "Player Killed", $contents); $contents = str_replace("CLOG", "Combat Logged", $contents); if(preg_match_all($pattern, $contents, $matches)){ echo "<strong>"; echo "<div style ='font:11px/21px Arial,tahoma,sans-serif;color:#2983CB'>Killboard Epoch Chernarus: <br>"; echo '', implode(" <br>", $matches[0]); echo "</strong>"; } else { echo "No kills yet. Looks like everyone is playing nice."; } ?> Wich does some of the same, atleast for the replacing. But here i just want it to display in descending order instead. Its far from pretty, i know, so if someone wants to clean it up aswell. That would be much appreciated too. Hope someone can help out a php noobie here
  22. hello dear php-experts, i want to run and show facebook-actiity feeds (in other words "streams of two different facebook sites) that said i cannot do this with one plugin - can i? well some guys taled bout a solution of copying and cloing a wordpress plugin I want to have multiple instances of the plugin running so i can have different related content on a single page. that said i heard that some guys just do one thing; they coly the copy the plugin. https://wordpress.org/support/topic/installing-2-copies-of-the-same-plugin?replies=8 but thie does not work - so i have to do one facebook-feed with a version like so question - how to include the code: https://developers.facebook.com/docs/plugins/activity Initialize the JavaScript SDK using this app: booksocial123 Include the JavaScript SDK on your page once, ideally right after the opening <body> tag. <div id="fb-root"></div> <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_GB/sdk.js#xfbml=1&appId=473241986032774&version=v2.0"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script> Place the code for your plugin wherever you want the plugin to appear on your page. <div class="fb-activity" data-site="facebook.com/literaturen" data-action="likes, recommends" data-width="350px" data-height="350px" data-colorscheme="light" data-header="true"></div> how to include that into a wordpress
  23. Hello, Basically ive got a html drop down list, with various options based on urgency. One of the options is "Can wait" and if the user selects this option I want them to be displayed with a date picker so that they can pick a date. Ive got a HTML5 date picker in the form but its displayed all the time, whereas im looking for it to be displayed only if the user picks "Can wait". Is there a method I could use to get that to work? I need to get this working and I have done research, but to no avail. Any help would be greatly appreciated. Thanks.
  24. I have a register form where a user enters a full name, email and password. I do not want to give them the option of choosing their own "username"; rather I want to automatically create the username from their "full name". So far I can create the username by removing space and symbols from full name. Like this. $fullname = trim($_GET['fullname']); $username = preg_replace('/\s+/', '', $fullname); Looking at that, John Smith would become "johnsmith". Since there could be dozens of people with the name "john smith", I was thinking of assigning unique number to each of them. Like this "johnsmith1", "johnsmith2", "johnsmith3"..etc. How would you say I go on incrementing the username like that?
  25. Hey guys, So I wanted to know what security measures I would have to take when retrieving user information from the database with the $_GET method. The $_Get would be the user_id so do I need to add some if statements to make sure its an integer, not empty etc. And what function would I use for in case of the user attempts to break the website by changing the url with commas,malicious code, etc.
×
×
  • 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.