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'm currently using a voting script, but have a problem with people voting more then once, and want to add a way to keep the voting unique and 1 per person via IP check can anybody assist me how to implement it in the following script please? <?php // the questions and the answers $pool_question="Do you think I should keep Galaxy Universe open?"; $pool_option[1]="Yes"; $pool_option[2]="No"; // If counter files are not available,they will be created // You may remove next lines after the first use of the script if (!file_exists("pool_5483543_1.txt")){ // next two lines will not work if writing permissions are not available // you may create the files bellow manualy with "0" as their unique content file_put_contents ("pool_5483543_1.txt",0); file_put_contents ("pool_5483543_2.txt",0); } // retrieve data saved in files $pool_responses[1]=file_get_contents("pool_5483543_1.txt"); $pool_responses[2]=file_get_contents("pool_5483543_2.txt"); // if user votes, increase corresponding value if ($_POST["5483543"] and $_POST["5483543b"]==""){ if ($_POST["5483543"]==1) {$pool_responses[1]++;file_put_contents("pool_5483543_1.txt",$pool_responses[1]);} if ($_POST["5483543"]==2) {$pool_responses[2]++;file_put_contents("pool_5483543_2.txt",$pool_responses[2]);} } // get percentajes for each answer in the pool // get total number of answers $total_responses=$pool_responses[1]+$pool_responses[2]; if ($total_responses==0){$total_responses=1;} // to avoid errors at start // compute percentajes (with one decimal number) $pool_percentaje[1] = round((100*$pool_responses[1])/$total_responses,1); $pool_percentaje[2] = round((100*$pool_responses[2])/$total_responses,1); // print the form, which includes de answers and the percentajes print "<center>\n"; print "<form method=post action=".$_SERVER["PHP_SELF"].">\n"; print "<b>".$pool_question."</b>\n"; print "<table cellpadding=4>\n<br>"; // answer 1 print "<tr>\n"; print "<td><input type=radio name=5483543 value=1> ".$pool_option[1]."</td>\n"; print "<td bgcolor=DDDDFF>" .$pool_responses[1]." (".$pool_percentaje[1]."%)</td>\n"; print "</tr>\n"; // answer 2 print "<tr>\n"; print "<td><input type=radio name=5483543 value=2> ".$pool_option[2]."</td>\n"; print "<td bgcolor=DDDDFF>" .$pool_responses[2]." (".$pool_percentaje[2]."%)</td>\n"; print "</tr>\n"; print "</table>\n"; // a simple control to avoid one user to vote several times if ($_POST["5483543"]){ print "<input type=hidden name=5483543b value=1>\n"; } print "<input TYPE=submit value=Add my answer>\n"; print "</form>\n"; print "</center>\n"; ?> The reason why I ask for IP check is I wan't to use $_SERVER["HTTP_X_MXIT_USERID_R"]; in the place of the Ip since it give a unique name via the platform I want to implement it.
  2. Hi, I have the below code and jquery in wordpress. I would like the form to auto submit, but at the moment I just get a 0 in the place of the heart icon. it seems to refresh but the form is not submitting the query. Thank you in advance <form id="lastviewer" class="ajax-form" action="<?php echo AJAX_URL; ?>" method="POST"> <?php if(ThemexUser::islastviewed(ThemexUser::$data['active_user']['ID'])) { ?> <a href="#" title="<?php _e('Remove from lastviewed', 'lovestory'); ?>" data-title="<?php _e('Add to Last Viewed', 'lovestory'); ?>" class="icon-heart submit-button current"></a> <input type="hidden" class="toggle" name="user_action" value="remove_lastviewed" data-value="add_lastviewed" /> <?php } else { ?> <a href="#" title="<?php _e('Add to Last Viewed', 'lovestory'); ?>" data-title="<?php _e('Remove from Last Viewed', 'lovestory'); ?>" class="icon-heart submit-button"></a> <input type="hidden" class="toggle" name="user_action" value="add_lastviewed" data-value="remove_lastviewed" /> <?php } ?> <input type="hidden" name="user_lastviewed" value="<?php echo ThemexUser::$data['active_user']['ID']; ?>" /> <input type="hidden" class="nonce" value="<?php echo wp_create_nonce(THEMEX_PREFIX.'nonce'); ?>" /> <input type="hidden" class="action" value="<?php echo THEMEX_PREFIX; ?>update_user" /> </form> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function() { window.setInterval(function() { AutoPost(); }, 3000); }); function AutoPost() { $.ajax({ type: "POST", url: "<?php echo AJAX_URL; ?>", success: function(data) { $("#lastviewer").html(data) ; } }); } </script>
  3. Hello my good people I'm doing a content manager system in PHP and mySQLi, following a serie of video tutorials. But in my project I am using a tree menu. In the front office all works smoothly (the tree menu displays all results - menu and submenus - and each button carries the information of the respective page). The problem is in the back office. The menu is there, in the url appears its id page but the CRUD, I can not put it to work. ======= CODE START ======= <!-- Gestor de Conteúdos Start --> <div class="container-fluid"> <!-- Conteúdo Fluido Start --> <div class="row-fluid row-offcanvas row-offcanvas-left"> <?php // INSERT QUERY if(isset($_POST['enviado']) == 1) { $header = mysqli_real_escape_string($dbc, $_POST['header']); $url = mysqli_real_escape_string($dbc, $_POST['url']); $user = $_POST['user']; $idPai = $_POST['idPai']; $menuNomePT = mysqli_real_escape_string($dbc, $_POST['menuNomePT']); $conteudo_pagina_PT = mysqli_real_escape_string($dbc, $_POST['conteudo_pagina_PT']); $menuNomeEN = mysqli_real_escape_string($dbc, $_POST['menuNomeEN']); $conteudo_pagina_EN = mysqli_real_escape_string($dbc, $_POST['conteudo_pagina_EN']); $q = "INSERT INTO menuCAL (header, url, user, idPai, menuNomePT, conteudo_pagina_PT, menuNomeEN, conteudo_pagina_EN) VALUES ('$header', '$_POST[url]', $_POST[user], '$_POST[idPai], '$menuNomePT, '$conteudo_pagina_PT', '$menuNomeEN', '$conteudo_pagina_EN'"; $r = mysqli_query($dbc, $q); ?> <div> <?php if($r) { $message = '<p>A página foi adicionada!</p>'; } else { $message = '<p>A página não foi adicionada, devido ao seguinte erro: '.mysqli_error($dbc); $message .= '<p>' .$q.'</p>'; } ?> </div> <?php } ?> <!-- Menu CAL Start --> <div class="col-sm-3 sidebar-offcanvas"> <?php //call the recursive function to print category listing category_tree(0); //Recursive php function function category_tree($menuPai){ global $dbc; $q = "SELECT * FROM menuCAL WHERE idPai ='".$menuPai."'"; $r = mysqli_query($dbc, $q); while($btnMenu = mysqli_fetch_assoc($r)): $i = 0; if ($i == 0) echo '<ul class="menuCAL">'; echo '<li><a href="?page='.$btnMenu['id'],'">' . $btnMenu['GlyPrincipal'] . $btnMenu['GlySecundario'] . $btnMenu['menuNomePT'], '</a>'; category_tree($btnMenu['id']); echo '</li>'; $i++; if ($i > 0) echo '</ul>'; endwhile; } ?> </div> <!-- Menu CAL End --> <!-- Conteúdo Start --> <div class="span10"> <div class="col-sm-12"> <!-- Título Start --> <h1 class="page-header"> <i class="fa fa-file"></i> Adicionar Página </h1> <ol class="breadcrumb"> <li> <a href="#"><i class="fa fa-pencil"></i> Conteúdos</a> </li> <li class="active"> <i class="fa fa-file"></i> Nova página </li> </ol> <!-- Título End --> </div> <!-- Textos & Formulários Start --> <div class="row"> <div class="col-lg-12"> <p><?php if(isset($message)) { echo $message; } ?></p> <?php // SELECT QUERY if(isset($_GET['id'])) { $q = "SELECT * FROM menuCAL WHERE id = $_GET[id]"; $r = mysqli_query($dbc, $q); $opened = mysqli_fetch_assoc($r); } ?> <!-- Formulário Start --> <form action="adicionar_pagina.php" method="post" role="form"> <!-- Campo header Start --> <div class="form-group"> <label for="header">Header:</label> <input type="text" class="form-control" name="header" id="header" value="<?php echo $opened['header']; ?>" placeholder="Texto descritivo a colocar no topo do website"> </div> <!-- Campo header End --> <!-- Campo Label Start --> <div class="form-group"> <label for="url">URL:</label> <input type="text" class="form-control" name="url" id="url" value="<?php echo $opened['url']; ?>" placeholder="Texto a colocar na URL (SEO)"> </div> <!-- Campo Label End --> <!-- Campo User Start --> <div class="form-group"> <label for="user">Administrador:</label> <select class="form-control" name="user" id="user"> <option value="0">›› Nenhum administrador</option> <?php $q = "SELECT id FROM users ORDER BY first ASC"; $r = mysqli_query ($dbc, $q); while ($user_list = mysqli_fetch_assoc($r)) { $user_data = data_user($dbc, $user_list['id']); ?> <option value="<?php echo $user_data['id'] ?>" <?php if($user_data['id'] == $opened['id']) { echo 'selected';} ?>><?php echo $user_data['fullname']; ?></option> <?php } ?> </select> </div> <!-- Campo User Start --> <!-- Campo ID Menu Pai Start --> <div class="form-group"> <label for="idPai">Adicionar a:</label> <select class="form-control" name="idPai" id="idPai"> <option value="0">›› Seleccione onde adicionar a nova página:</option> <?php $q = "SELECT menuNomePT FROM menuCAL WHERE idPai = 0"; $r = mysqli_query ($dbc, $q); while ($submenus = mysqli_fetch_assoc($r)) { ?> <option value="<?php echo $submenus['idPai']; ?>"><?php echo $submenus['menuNomePT']; ?></option> <?php } ?> </select> </div> <!-- Campo ID Menu Pai Start --> <!-- Campo menuNomePT Start --> <div class="form-group"> <label for="menuNomePT">Título PT:</label> <input type="text" class="form-control" name="menuNomePT" id="menuNomePT" value="<?php echo $opened['menuNomePT']; ?>" placeholder="Insira o título em Português"> </div> <!-- Campo menuNomePT End --> <!-- Campo conteudo_pagina_PT Start --> <div class="form-group"> <label for="conteudo_pagina_EN">Conteúdos PT:</label> <textarea class="form-control" name="conteudo_pagina_PT" rows="12" id="conteudo_pagina_PT" placeholder="Insira os textos em Português"><?php echo $opened['conteudo_pagina_PT']; ?></textarea> </div> <!-- Campo conteudo_pagina_PT End --> <!-- Campo menuNomeEN Start --> <div class="form-group"> <label for="menuNomeEN">Título EN:</label> <input type="text" class="form-control" name="menuNomeEN" id="menuNomeEN" value="<?php echo $opened['menuNomePT']; ?>" placeholder="Insira o título em Inglês"> </div> <!-- Campo menuNomeEN End --> <!-- Campo conteudo_pagina_EN Start --> <div class="form-group"> <label for="conteudo_pagina_EN">Conteúdos EN:</label> <textarea class="form-control" name="conteudo_pagina_EN" rows="12" id="conteudo_pagina_EN" placeholder="Insira os textos em Inglês"><?php echo $opened['conteudo_pagina_PT']; ?></textarea> </div> <!-- Campo conteudo_pagina_EN End --> <button type="submit" class="btn btn-default adic_concluir">Gravar</button> <input type="hidden" name="enviado" value="1"> </div> </form> <!-- Formulário End --> </div> <!-- Debug Panel Start --> <?php if($debug == 1) { include('widgets/debug.php'); } ?> <!-- Debug Panel End --> </div> <!-- Textos & Formulários End --> </div> <!-- Conteúdo End --> </div> <!-- Conteúdo Fluido Start --> </div> <!-- Gestor de Conteúdos End --> ======= CODE END ======= I can not do the INSERT or UPDATE query, using the form so that the "user" and the "idPai" (a category id), can be created or changed in the database. I tried to echo the database result, but nothing append And in the second query (in red in the code), gives me an error (Undefined variable: opened in …). Obviously something is wrong, but i can't see what! :/ The database: Can Someone help me? Please !! Thank U
  4. Hello friends, I am a novice in php. Though I create 2 scripts: 1. students registration form 2. search students by Registration Number Our students' Registration Numbers are as follows: nifeA001, nifeA002 & so on... But when someone enter just "nife" or "n" or "A" etc all the students's data is showing. I want that students can search data by entering only Full Registration Number not a Part. I am placing the search.php code below. Please help me out.... ----------------- Search.php ------------------ <?php mysql_connect("localhost", "root", "") or die("could not connect"); mysql_select_db("student") or die("could not connect"); //collect if(isset($_POST['search'])) { $searchq = $_POST['search']; $searchq = preg_replace("#[^0-9a-z]#i", "", $searchq); //here $query = mysql_query("SELECT * FROM user WHERE registration LIKE '%$searchq%'") or die("could not search!"); $count = mysql_num_rows($query); if($count == 0){ $output = 'There was no search results!'; }else{ while($row = mysql_fetch_array($query)) { $fname = $row['firstname']; $lname = $row['surname']; $id = $row['registration']; $output .= '<div> '.$id.' '.$fname.' '.$lname.'</div>'; } } } ?> <html> <head> </head> <body> <form action="form.php" method="post"> <input type="text" name="search" placeholder="search for students.." <input type="submit" value=">>" /> </form> <?php print("$output");?> </body> </html>
  5. Hello Everybody I usually work with C#, but I'm doing a website right now and have a question: I want a picture in my header and when I change the window size the image may not move. My code so far: #a1 { position: relative; top:-175px; left:0px; width:50px; height:50px; background-image:url(http://domain.png); background-repeat:no-repeat;} </style> Hope someone can answer this question easy
  6. I'm running the latest stable version of PHP in Apache Server on Windows 7 64-bit. It working fine and set up correctly. I'd like to use ENVIRONMENT VARIABLES or a variable like "%current_directory%" or "..\%current_directory%" in the configuration files for PHP, php.ini. Is this possible? Is php.ini a parsed file, can variables be define and used in it? Help would be much appreciated
  7. I am using the dragdrop functionality on a page which also updates the database.Drag and drop is working fine But i am having difficulty to determine which events to use to update the database. Here is my code <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>jQuery UI Sortable - Portlets</title> <link rel="stylesheet" href="//code.jquery.com/ui/1.11.1/themes/smoothness/jquery-ui.css"> <script src="//code.jquery.com/jquery-1.10.2.js"></script> <script src="//code.jquery.com/ui/1.11.1/jquery-ui.js"></script> <!--<link rel="stylesheet" href="/resources/demos/style.css">--> <style> body { min-width: 520px; } .interview-questions-column { width: 400px; float: left; padding-bottom: 100px; } .question-bank { width: 500px; float: left; padding-bottom: 100px; } .portlet { margin: 0 1em 1em 0; padding: 0.3em; } .portlet-header { padding: 0.2em 0.3em; margin-bottom: 0.5em; position: relative; } .portlet-toggle { position: absolute; top: 50%; right: 0; margin-top: -8px; } .portlet-content { padding: 0.4em; } .portlet-placeholder { border: 1px dotted black; margin: 0 1em 1em 0; height: 50px; } .sortable { border: 1px solid #eee; width: 95%; min-height: 20px; list-style-type: none; margin: 0; padding: 5px 0 0 0; float: left; margin-right: 10px; } .sortable li { margin: 0 5px 5px 5px; padding: 5px; font-size: 1.2em; width: 95%; } .bank-quertion-sotrable { border: 1px solid #eee; width: 150px; min-height: 20px; list-style-type: none; margin: 0; padding: 5px 0 0 0; float: left; margin-right: 10px; } .bank-quertion-sotrable li{ margin: 0 5px 5px 5px; padding: 5px; font-size: 1.2em; width: 200px; } .ui-state-default { height: 1.5em; line-height: 1.2em; } </style> <script> $(function() { $( ".interview-questions-column" ).sortable({ connectWith: ".interview-questions-column", handle: ".portlet-header", cancel: ".portlet-toggle", placeholder: "portlet-placeholder ui-corner-all" }); $( ".portlet" ) .addClass( "ui-widget ui-widget-content ui-helper-clearfix ui-corner-all" ) .find( ".portlet-header" ) .addClass( "ui-widget-header ui-corner-all" ) .prepend( "<span class='ui-icon ui-icon-minusthick portlet-toggle'></span>"); $( ".portlet-toggle" ).click(function() { var icon = $( this ); icon.toggleClass( "ui-icon-minusthick ui-icon-plusthick" ); icon.closest( ".portlet" ).find( ".portlet-content" ).toggle(); }); }); $(function() { $( ".sortable" ).sortable({ placeholder: "ui-state-default", connectWith: ".connectedSortable", /*receive: function(event, ui) { // only perform for sub drop downs if($(this).hasClass('question_bank')) { // if the item doesn't have the matching sub class if (!$(this).hasClass($(ui.item).attr('class'))) { // cancel the sortable $(ui.sender).sortable('cancel'); } } alert('receive'); alert(ui.sender.attr("dataid")); alert(ui.sender.toSource()); // alert("[" + this.id + "] received [" + ui.item.attr("id") + "] from [" + ui.sender.attr("id") + "]"); },*/ update: function (event, ui) { //serial = $('#sortableF').sortable('serialize'); var data = $(this).sortable('serialize'); alert(data); //alert('update sortable'); //alert("[" + this.id + "] received [" + ui.item.attr("id") + "] from [" + ui.sender.attr("id") + "]"); // POST to server using $.post or $.ajax /*$.ajax({ data: 'test', type: 'POST', url: '/your/url/here' });*/ } }).disableSelection(); }); $(function() { $( ".draggable" ).draggable({ connectToSortable: ".sortable", helper: "clone", /*revert: function(valid) { if(valid) { alert("drop is valid"); //Dropped in a valid location } else { alert("drop is invalid"); //Dropped in an invalid location } // return !valid; return false; }*/ stop: function( event, ui ) { // alert(ui); // alert("[" + this.id + "] received [" + ui.item.attr("id") + "] from [" + ui.sender.attr("id") + "]"); } }); }); $( "ul, li" ).disableSelection(); </script> </head> <body> <div class="interview-questions-column"> <div class="portlet"> <div class="portlet-header">Feeds</div> <div class="portlet-content"> <ul id="sortableF" class="connectedSortable sortable"> <li class="ui-state-default" id="item-1">Item 1</li> <li class="ui-state-default" id="item-2">Item 2</li> <li class="ui-state-default" id="item-3">Item 3</li> <li class="ui-state-default" id="item-4">Item 4</li> <li class="ui-state-default" id="item-5">Item 5</li> </ul> </div> </div> <div class="portlet"> <div class="portlet-header">News</div> <div class="portlet-content"> <ul id="sortableS" class="connectedSortable sortable"> <li class="ui-state-default" id="item-6">Item 1</li> <li class="ui-state-default" id="item-7">Item 2</li> <li class="ui-state-default" id="item-8">Item 3</li> <li class="ui-state-default" id="item-9">Item 4</li> <li class="ui-state-default" id="item-10">Item 5</li> </ul> </div> </div> <div class="portlet"> <div class="portlet-header">Shopping</div> <div class="portlet-content"> <ul id="sortableS" class="connectedSortable sortable"> <li class="ui-state-default" id="item-11">Item 1</li> <li class="ui-state-default" id="item-12">Item 2</li> <li class="ui-state-default" id="item-13">Item 3</li> <li class="ui-state-default" id="item-14">Item 4</li> <li class="ui-state-default" id="item-15">Item 5</li> </ul> </div> </div> <div class="portlet"> <div class="portlet-header">Links</div> <div class="portlet-content"> <ul id="sortableS" class="connectedSortable sortable"> <li class="ui-state-default" id="item-16">Item 1</li> <li class="ui-state-default" id="item-17">Item 2</li> <li class="ui-state-default" id="item-18">Item 3</li> <li class="ui-state-default" id="item-19">Item 4</li> <li class="ui-state-default" id="item-20">Item 5</li> </ul> </div> </div> <div class="portlet"> <div class="portlet-header">Images</div> <div class="portlet-content"> <ul id="sortableS" class="connectedSortable sortable"> <li class="ui-state-default" id="item-21">Item 1</li> <li class="ui-state-default" id="item-22">Item 2</li> <li class="ui-state-default" id="item-23">Item 3</li> <li class="ui-state-default" id="item-24">Item 4</li> <li class="ui-state-default" id="item-25">Item 5</li> </ul> </div> </div> </div> <div class="question-bank"> <div class="portlet"> <div class="portlet-header">Question bank</div> <div class="portlet-content"> <ul id="question_back" class="connectedSortable bank-quertion-sotrable"> <li class="ui-state-default draggable" id="item-26">Item 1</li> <li class="ui-state-default draggable" id="item-27">Item 2</li> <li class="ui-state-default draggable" id="item-28">Item 3</li> <li class="ui-state-default draggable" id="item-29">Item 4</li> <li class="ui-state-default draggable" id="item-30">Item 5</li> </ul> </div> </div> </div> </body> </html> Basically above code will form few boxes with items(which are actually questions) in it. There is one box on the right side with heading "Question Bank". From the "Question Bank" we can drag the questions to other boxes but can't do the reverse(this is also working). Also we can sort the questions within the box or drag the questions from one box to another. Box heading are the categories and items are questions associated to that categories. What i need is : Event that updates the database when we drag the questions from "Question Bank" to any box on the left side. Please note Questions in the "Question Bank" are pre created coming from database. Event that updates the database when we sort the questions within the box. Event that updates the database when we drag the question from one box to another box. it should also do the sorting for that two boxes. Event that updates the database when we sort the boxes. Here is the JS Fiddle link jsfiddle.net/6o30rrzx Question Bank is comming on the bottom of the page instead of on the right side any advice and suggestions will be greatly appreciated Thank you for reading this post.
  8. Hi, I have a php script that generates a select dropdown box <option value="1"> Bob </option> <option value="2"> Tim </option> <option value="3"> Sam </option> <option value="4"> Phil </option> I then have the following javascript to produce my google api graph: <script type="text/javascript"> google.load('visualization', '1', {'packages':['corechart']}); google.setOnLoadCallback(drawChart); function drawChart() { var jsonData = $.ajax({ url: "test1.php", dataType:"json", async: false, }).responseText; var data = new google.visualization.DataTable(jsonData); var chart = new google.visualization.LineChart(document.getElementById('chart_div')); chart.draw(data); } </script> This then runs a php script that returns the data back in Json format. How can I pass the <option value=""> through the to the test1.php script to generate the json data based on the the value selected i.e 1, 2, 3 etc. i an new at javascript and the google api can anyone let me know how I can get this variable sent through by the google api script. and for the graph to refresh every time another option is chosen. Thanks kris
  9. Hi, I'm a novice and have the below code in a Wordpress theme. I'm trying to get the form to submit automatically so it logs an entry into the MySql db as though the person clicked the heart icon (submit). Ideally I subsequently want to hide the heart icon so on load maybe after 3 seconds the entry is auto fired to the MySql DB. I have got as far as the manual click adding the entry, however can't get to to auto submit, any gel would be appreciated. Thank you in advance. ////PHP Form///// <form class="ajax-form" action="<?php echo AJAX_URL; ?>" method="POST"> <?php if(ThemexUser::islastviewed(ThemexUser::$data['active_user']['ID'])) { ?> <a href="#" title="<?php _e('Remove from lastviewed', 'lovestory'); ?>" data-title="<?php _e('Add to Last Viewed', 'lovestory'); ?>" class="icon-heart submit-button current"></a> <input type="hidden" class="toggle" name="user_action" value="remove_lastviewed" data-value="add_lastviewed" /> <?php } else { ?> <a href="#" title="<?php _e('Add to Last Viewed', 'lovestory'); ?>" data-title="<?php _e('Remove from Last Viewed', 'lovestory'); ?>" class="icon-heart submit-button"></a> <input type="hidden" class="toggle" name="user_action" value="add_lastviewed" data-value="remove_lastviewed" /> <?php } ?> <input type="hidden" name="user_lastviewed" value="<?php echo ThemexUser::$data['active_user']['ID']; ?>" /> <input type="hidden" class="nonce" value="<?php echo wp_create_nonce(THEMEX_PREFIX.'nonce'); ?>" /> <input type="hidden" class="action" value="<?php echo THEMEX_PREFIX; ?>update_user" /> </form> ////Ajax///// //Elements var themeElements = { ajaxForm: '.ajax-form', } //AJAX Form $(themeElements.ajaxForm).each(function() { var form=$(this); form.submit(function() { var message=form.find('.message'), loader=form.find('.loader'), toggle=form.find('.toggle'), button=form.find(themeElements.submitButton), title=form.find(themeElements.submitButton).data('title'); var data={ action: form.find('.action').val(), nonce: form.find('.nonce').val(), data: form.serialize() } loader.show(); button.addClass('disabled').toggleClass('current'); if(!message.hasClass('static')) { message.slideUp(300, function() { $(themeElements.colorboxLink).colorbox.resize(); }); } jQuery.post(form.attr('action'), data, function(response) { if(jQuery('.redirect', response).length) { if(jQuery('.redirect', response).attr('href')) { window.location.href=jQuery('.redirect',response).attr('href'); } else { window.location.reload(); } message.remove(); } if(title) { button.data('title', button.attr('title')); button.attr('title', title); } toggle.each(function() { var value=toggle.val(); toggle.val(toggle.data('value')); toggle.data('value', value); }); loader.hide(); button.removeClass('disabled'); if(response!='' && response!='0' && response!='-1') { if(message.hasClass('popup')) { $.colorbox({html:'<div class="popup">'+response+'</div>'}); } else if(message.hasClass('static')) { message.append(response); } else { message.html(response).slideDown(300, function() { $(themeElements.colorboxLink).colorbox.resize(); }); } } form.find('.temporary').val(''); form.find('.scroll').each(function() { $(this).scrollTop($(this)[0].scrollHeight); }); }); return false; }); }); Thank you
  10. I need to set up a threaded comments system in a PHP project and I got this script shown below from http://www.jongales.com/blog/2009/01/27/php-class-for-threaded-comments/#comment-436261 class Threaded_comments { public $parents = array(); public $children = array(); /** * @param array $comments */ function __construct($comments) { foreach ($comments as $comment) { if ($comment['parent_id'] === NULL) { $this->parents[$comment['id']][] = $comment; } else { $this->children[$comment['parent_id']][] = $comment; } } } /** * @param array $comment * @param int $depth */ private function format_comment($comment, $depth) { for ($depth; $depth > 0; $depth--) { echo "\t"; } echo $comment['text']; echo "\n"; } /** * @param array $comment * @param int $depth */ private function print_parent($comment, $depth = 0) { foreach ($comment as $c) { $this->format_comment($c, $depth); if (isset($this->children[$c['id']])) { $this->print_parent($this->children[$c['id']], $depth + 1); } } } public function print_comments() { foreach ($this->parents as $c) { $this->print_parent($c); } } } Here’s the example usage with the data provided as an array: $comments = array( array('id'=>1, 'parent_id'=>NULL, 'text'=>'Parent'), array('id'=>2, 'parent_id'=>1, 'text'=>'Child'), array('id'=>3, 'parent_id'=>2, 'text'=>'Child Third level'), array('id'=>4, 'parent_id'=>NULL, 'text'=>'Second Parent'), array('id'=>5, 'parent_id'=>4, 'text'=>'Second Child') ); $threaded_comments = new Threaded_comments($comments); $threaded_comments->print_comments(); I have a sample select query that pulls data from a database and stores the result in the $comments array as shown below. The $comments array is then passed as an argument to the $threaded_comments object: $sql = 'SELECT * FROM test_comments'; // submit the query and capture the result $result = $conn->query($sql); $comments = array(); while ($row = $result->fetch_assoc()) { $comments[] = $row; } The challenge is that nothing is printed to the screen when I run the script. Inspection of the comments array with the var_dump function is shown below: array (size=4) 0 => array (size=3) 'id' => string '1' (length=1) 'parent_id' => string '0' (length=1) 'text' => string 'comment' (length=7) 1 => array (size=3) 'id' => string '2' (length=1) 'parent_id' => string '0' (length=1) 'text' => string 'comment' (length=7) 2 => array (size=3) 'id' => string '3' (length=1) 'parent_id' => string '1' (length=1) 'text' => string 'comment ' (length= 3 => array (size=3) 'id' => string '4' (length=1) 'parent_id' => string '3' (length=1) 'text' => string 'comment ' (length= I was wondering if the array format from my select query is the issue? Could anyone provide a clue as to how to fix this? Thanks.
  11. Hey guys! im currently learning javascript, PHP and SQL. I have a pretty solid understanding of HTML and CSS. I want to make a site similar to facebook (a good facebook). this is going to be a big project and i plan on moving to a bigger server system in a year or so to keep up with demands. Heres how the site will function: 1. Basic registration/splash page. I understand that the finished form is sent to a php file on the server side, correct? (ill change my server name files of course) 2. after the registration page, while the user is logged in with their new account, there are 3 pages after that that explain what the website is all about and how to use it. the last page allows the user to setup their profile information, ask friends to join, and asks what type of things they like. After the last page, it sends the user to their main control panel, where social media feed can be seen, friends and online chats, news, advertisements, links, pages and groups (think facebook and linkedin) 3. the user will have the ability to look at their profile (not the control panel), and of course switch back to their control panel. social media, friends, groups and ads will also be on their individual profile page as well. 4. i want the site to have two views: a standard view and an enhanced view. the enhanced view will reposition divs and all that stuff so they can see a background image (either stock or one they uploaded) this image will eventually change to an animated image of a 3d environment. 5. the site is going to be heavily social media based. This means social media feeds, image uploading, a structured comment system, a friend system, search functions and targeted advertising. This is obviously a lot to ask, but since their is so much to learn related to PHP and SQL, can someone point me to the right tutorials on how to get these things done? I am currently learning javascript, PHP and SQL on lynda.com. Expect me to be on this forum a lot and asking a lot of questions. Thanks for any help.
  12. Hello every body,, i want to create a new database (auto generate duty assigned using form) in PHP and mysql.. i have four input fields:- Name, Subject, Class & weekly lectures now i want to insert name,subject & class into database, when i insert number of weekly lecture in field four.. insert automaticlly in database multiple time which i write in field four (weekly lecture) database: table structure i have already is::: id-name-subject-class-period-monday-tuesday-wednesday-thursday-friday-saturday anybody please help me to create this database or just insert query ....
  13. Hi, I've currently started to modify a chat script of mine to output a moderation panel but the moderation page seems empty(blank) every time I load it. What im trying to do is to take the ID part in my URL via the $_GET and look it up in my database table in the column named id, then select that specific row to be able to retrieve the StringyChat_ip and place it into another table to ban the IP and the second thing im trying to do is to be able to delete the specific row from my table. My Http link look something like and my ban.php page where I want to lookup the 159 part and do the banning etc looks like <? include("admin_code_header.php"); if ($_POST["DeletePost"]) { $id = $_POST['id']; $query = "DELETE FROM ".$dbTable." WHERE id='".$id."'"; mysql_query($query); echo "ID removed from system: ".$id; } if ($_POST["BanIP"]) { $IP_To_Add = $_POST["ip"]; $sql = "INSERT INTO ".$IPBanTable." (ip) VALUES (\"$IP_To_Add\")"; $result = mysql_query($sql); } $result = mysql_query("SELECT * FROM ".$dbTable." WHERE id='".$id."'",$db); while ($myrow = mysql_fetch_array($result)) { $msg = $myrow["StringyChat_message"]; $idm = $myrow["id"]; ?> <html> <form name="form<? echo $myrow["id"];?>" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <input name="DeletePost" type="submit" id="DeletePost" value="Delete"> <input name="BanIP" type="submit" id="BanIP" value="Ban <? echo $myrow["StringyChat_ip"];?>"> </form> </html> <? } ?>
  14. Hey guys I am stuck on how to best create a php function to do the following. I need to echo out 4 restaurants. I have a database of numerous restaurant categories: breakfast, lunch, dinner, and coffee. In this database some categories have more results than others. Basically I want to randomly choose results from each category query, Breakfast, Lunch, and dinner to create 4 echoed results. (I understand that one category will have an extra result as there are 3 categories and 4 echoed results.) I do not want one category of restaurant to bump out another category because it has more results. Also, if there are not enough or no results from one category, I want extra results from the other queries to make up for it so that there are always 4 echoed items. Finally, if there are not enough results from breakfast, lunch, dinner to make 4 echoed items, I would like Coffee to fill the 4 required results. Randomly echo 4 results from the below primary queries: Primary Query: Breakfast Restraunts Query Primary Query: Lunch Restraunts Query Primary Query: Dinner Restraunts Query Get results from secondary query if Primary queries can’t echo 4 results: Secondary Query: Coffee Shops Query I hope this makes sense. I understand how to do the mysql queries, I just don't know how to do the php function to echo the results as required. Any help would be appreciated!
  15. I have a form with PHP validation and also a mysqli query checking for duplicates in the database for mailing address and email address in mysql. It works fine but the customers are adding spaces in the mailing address for example 111 mailing address A V E, 1 1 1 ma iling address A V E etc. and my sql query doesn't see that as an address that's a duplicate. Their alslo adding email address like my@emailaddress.com and m.y@emailaddress.com, m.y.2@emailaddress.com etc to bypass that comparision also. Is there anyway to stop this from happening?
  16. Hi, I had a chat script lying around but wanted to add a login form in case the mxitid wasn't found in the database so I made a few changes to the script to check for records in databases and retrieving the username according the mxit ID. but after I made few changes im getting syntax errors can someone maybe tell me where I made mistakes please. <?php // database connection info $conn = mysql_connect('*******','********','*******') or trigger_error("SQL", E_USER_ERROR); $db = mysql_select_db('************',$conn) or trigger_error("SQL", E_USER_ERROR); $query0 = mysql_query("SELECT username FROM Users WHERE mxitid=$mid", $con); $result = mysql_query($query0); $myrows = mysql_fetch_array($result); if (mysql_num_rows($query0) != 0) { echo "define('TIMEZONE', 'Africa/Harare'); date_default_timezone_set(TIMEZONE); echo "<html><br> <span style="color:red"><b><u>Chat Beta: Errors may apply please send feedback with contact us regarding problems!</u></b></span> </html>"; // find out how many rows are in the table $sql = "SELECT COUNT(*) FROM StringyChat"; $result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR); $r = mysql_fetch_row($result); $numrows = $r[0]; // number of rows to show per page $rowsperpage = 20; // find out total pages $totalpages = ceil($numrows / $rowsperpage); // get the current page or set a default if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) { // cast var as int $currentpage = (int) $_GET['currentpage']; } else { // default page num $currentpage = 1; } // end if // if current page is greater than total pages... if ($currentpage > $totalpages) { // set current page to last page $currentpage = $totalpages; } // end if // if current page is less than first page... if ($currentpage < 1) { // set current page to first page $currentpage = 1; } // end if // the offset of the list, based on current page $offset = ($currentpage - 1) * $rowsperpage; /* * StringyChat * * Please refer to readme.txt supplied with the StringyChat distribution for information on * installing and configuring. * */ define('TIMEZONE', 'Africa/Harare'); date_default_timezone_set(TIMEZONE); include("chat_code_header.php"); $result = mysql_query("SELECT * FROM ".$ConfigTable, $db); $myrow = mysql_fetch_array($result); $domain_installed = $myrow["domain_installed"]; // The domain StringyChat is installed on $install_url = $myrow["install_url"]; // URL to install dir of StringyChat $name_size = $myrow["name_size"]; // Maximum size of the name $message_size = $myrow["message_size"]; // Maximum message size. Do not exceed 250 as this is the database limit. $line_length = $myrow["line_length"]; // Maximum length of words in a line. Anything above this value will be split. $ShowPostNum = $myrow["show_posts"]; // The number of historic posts to load and display. $email_notification = $myrow["email_notification"]; // Send email to administrator when new posts are made. 0 = No, 1 = Yes $email_notification_to = $myrow["email_notification_to"]; // The email address to send notifications to if ($_SERVER['REQUEST_METHOD'] == "POST" && !empty($_POST['StringyChat_name'])) { $StringyChat_name = $_POST['StringyChat_name']; $StringyChat_message = $_POST['StringyChat_message']; } <div id="StringyChat"> // Check if visitor's IP is banned. If so, do not display the form, // show a banned IP message instead. $name = $myrows["Username"]; if(!isset($name)) { $name = "SYSOP"; } $ip = $_SERVER["REMOTE_ADDR"]; $sql = "SELECT * FROM StringyChat_IPBan WHERE ip=\"$ip\""; $result = mysql_query($sql); $myrow = mysql_fetch_array($result); if($myrow["ip"] == "") { // Checks if IP not found in banned list ?> <html><form name="StringyChat_form" method="POST" action="<? echo $_SERVER['REQUEST_URI']; ?>"> <input type="hidden" name="StringyChat_name" class="StringyChatFrm" value="<?php echo $name ?>" size="20"> <textarea name="StringyChat_message" class="StringyChatFrm" cols="20" rows="1"></textarea> <br> <input name="StringyChat_submit" class="StringyChatFrm" type="submit" value="Post Message"> </form> </html> <? } else { echo "Posting disabled - Your IP has been banned."; } // Should we try to create a post? if (isset($StringyChat_name) && isset($StringyChat_message)) { // Remove whitespaces and slashes. $name = trim(stripslashes($StringyChat_name)); $message = trim(stripslashes($StringyChat_message)); // Check name and message have been entered. if (strlen($name) > 0 && strlen($message) > 0) { // Limit the size of the fields as per variable defnitions. if (strlen($name) > $name_size) { $name = substr($name, 0, $name_size); } if (strlen($message) > $message_size) { $message = substr($message, 0, $message_size); } // Remove new lines from name. $name = str_replace("\n", " ", $name); // Stripping out \r's so email formattnig appears correctly. $message = str_replace("\r", "", $message); // Create an email-friendly version of the message. $message_emailable = str_replace("<br>", "\n", $message); $result_wordswap = mysql_query("SELECT * FROM ".$WordBanTable,$db); while ($myrow_wordswap = mysql_fetch_array($result_wordswap)) { $the_word = $myrow_wordswap["word"]; $message_emailable = ereg_replace($the_word, "!*#$%",$message_emailable); } // Replace the new lines with encoded line breaks for HTML (thanks milahu). $message = str_replace("\n", "c#lb", $message); // Use HTML encoding on ame and message so database doesn't misinterpret data. $name = htmlentities($name); $message = htmlentities($message, ENT_COMPAT); // IP address of submitter and time of post. $ip = $_SERVER["REMOTE_ADDR"]; $name = $_SERVER["HTTP_X_MXIT_NICK"]; $msg = $_POST['StringyChat_message']; $post_time = date("U"); $mxitid = $_SERVER["HTTP_X_MXIT_LOGIN"]; if(!isset($mxitid)) { $mxitid = "DEFAULT"; } if(!isset($name)) { $name = "SYSOP"; } // check to see if a duplicate exists $sql = "SELECT * FROM StringyChat WHERE StringyChat_ip=\"$ip\" AND StringyChat_message=\"$msg\" AND StringyChat_time>($post_time - 1800 )"; $result = mysql_query($sql); $myrow = mysql_fetch_array($result); if($myrow["StringyChat_message"] == "") { // Checks if record not matching in db // Save the record $sql = "INSERT INTO StringyChat (StringyChat_ip,StringyChat_name,StringyChat_message,StringyChat_time) VALUES (\"$ip\",\"$name\",\"$msg\",$post_time)"; $result = mysql_query($sql); } else { echo "Duplicate post detected<br>"; } } else { echo "<font color=\"red\">You must Type a message</font><br><br>"; } unset($_POST["StringyChat_name"]); unset($_POST["StringyChat_message"]); unset($StringyChat_ip); unset($StringyChat_name); unset($StringyChat_message); unset($StringyChat_time); unset($mxit_id); } // get the info from the db $sql = "SELECT StringyChat_time, StringyChat_name, StringyChat_message FROM StringyChat ORDER BY id DESC LIMIT $offset, $rowsperpage"; $result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR); function filterBadWords($str) { $result1 = mysql_query("SELECT word FROM StringyChat_WordBan") or die(mysql_error()); $replacements = ":-x"; while($row = mysql_fetch_assoc($result1)) { $str = eregi_replace($row['word'], str_repeat(':-x', strlen($row['word'])), $str); } return $str; } // while there are rows to be fetched... while ($list = mysql_fetch_assoc($result)) //while (($pmsg = $list['StringyChat_message'] == $bwords) ? ":-x" : $list['StringyChat_message']) { // echo data //echo ($pmsg = ($list['StringyChat_message'] == $bwords) ? ":-x" : $list['StringyChat_message']) $admin = array('SYSOP','cobusbo'); if (in_array($list['StringyChat_name'], $admin)) { print '<span style="color:#828282">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] ) . ') ' . '</span>' . '<span style="color:red">' . '<b>' . $list['StringyChat_name'] . '</b>' . ' : ' . filterBadWords($list['StringyChat_message']) . '</span>' . '<br />' . '<p>'; } else { print '<span style="color:#828282">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] ) . ') ' . '</span>' . '<b>' . $list['StringyChat_name'] . '</b>' . ' : ' . filterBadWords($list['StringyChat_message']) . '<br />' . '<p>'; } } // Load up the last few posts. The number to load is defined by the "ShowPostNum" variable. $result = mysql_query("SELECT * FROM ".$dbTable." ORDER BY StringyChat_time DESC LIMIT " . $ShowPostNum,$db); include("sort_widths.php"); while ($myrow = mysql_fetch_array($result)) { $msg = $myrow["StringyChat_message"]; // Convert the encoded line break into an actual <br> tag (thanks milahu) $msg = str_replace("c#lb", "<br>", $msg); // Convert the encoded image tag into a html tag $msg = eregi_replace("im#([a-z]{3})", "<img src=\"http://".$install_url."images/\\1.gif\" alt=\"emoticon\">",$msg); // split the lines $msg = htmlwrap($msg, $line_length); $result_wordswap = mysql_query("SELECT * FROM ".$WordBanTable,$db); while ($myrow_wordswap = mysql_fetch_array($result_wordswap)) { $the_word = $myrow_wordswap["word"]; $msg = ereg_replace($the_word, ":-x",$msg); } } ?> <? // end while /****** build the pagination links ******/ // range of num links to show $range = 3; // if not on page 1, don't show back links if ($currentpage > 1) { // show << link to go back to page 1 echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=1'><<</a> "; // get previous page num $prevpage = $currentpage - 1; // show < link to go back to 1 page echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage'><</a> "; } // end if // loop to show links to range of pages around current page for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) { // if it's a valid page number... if (($x > 0) && ($x <= $totalpages)) { // if we're on current page... if ($x == $currentpage) { // 'highlight' it but don't make a link echo " [<b>$x</b>] "; // if not current page... } else { // make it a link echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$x'>$x</a> "; } // end else } // end if } // end for // if not on last page, show forward and last page links if ($currentpage != $totalpages) { // get next page $nextpage = $currentpage + 1; // echo forward link for next page echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage'>></a> "; // echo forward link for lastpage echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages'>>></a> "; } // end if /****** end build pagination links ******/ ?><br> <html> <i>Type your Message here...</i>:<br></html> "; } else { <html> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="GET"> Username:<br> <input type="text" name="username" ><br> <input type="hidden" value="<?php echo $_SERVER['HTTP_X_MXIT_LOGIN']; ?>" name"userid" > <br><br> <input type="submit" value="Submit"> </form> </html> <? $usernames = $_GET['username']; $mid = $_GET['userid']; $sql0 = "INSERT INTO Users (username,mxitid) VALUES (\"$usernames\",\"$mid\")"; $result = mysql_query($sql0); ?> }
  17. I have made a mutual friend system like facebook and it shows all the mutual friends but sometimes it shows it twice because your 2 friends might be friends with one person so it echos the same person twice so i wanna only show the person once and the most repeated should show on the top and the less repeated person should show at bottom!
  18. Hi PHP Freaks. Noobie here. Trying to learn PHP, following lecturesnippets.com PHP lessons. This is lesson 38. This seems like it should be simple, but no matter what I do, I can't get the database to update. Any help would be greatly appreciated. Thanks. Here's my code right now: <html> <head> </head> <body> <?php $con = mysqli_connect("localhost","Eric","******"); if (!$con){ die("Cannot connect:" . mysqli_connect_error()); } mysqli_select_db($con,"snippets"); if (isset($_POST['update'])){ $UpdateQuery = "UPDATE lectures SET Topic = '$_POST', Name='$_POST[name]', Attendance= '$_POST[attendance]' WHERE Topic='$_POST[hidden]'"; mysqli_query($con,$UpdateQuery); }; $sql = "SELECT * FROM lectures"; $myData = mysqli_query($con,$sql); echo "<table border=1> <tr> <th>Topic</th> <th>Name</th> <th>Attendance</th> </tr>"; while($record = mysqli_fetch_array($myData)){ echo"<form action=mydata3.php method=post>"; echo "<tr>"; echo "<td>" . "<input type=text name=topic value=" . $record['Topic'] . "> </td>"; echo "<td>" . "<input type=text name=name value=" . $record['Name'] . "> </td>"; echo "<td>" . "<input type=text name=attendance value=" . $record['Attendance'] . "> </td>"; echo "<td>" . "<input type=hidden name=hidden value=" . $record['Topic'] . "> </td>"; echo "<td>" . "<input type=submit name=submit value=update" . "> </td>"; echo "</form>"; } echo"</table>"; mysqli_close($con); ?> </body> </html>
  19. Hi guys, I am creating a piece of code that blocks a user a for 48 hours after attempting to login 5 times with the wrong password, within a 24hour period. If the user logs in successful within the 24hr and, it should reset the attempt count. The issue I'm having ATM is that with the attempt count, It is only updating the first row of that user, if i attempt more times. Here is an example of whats going on: User - Time - Attempt- count() User 1 10:00pm Attempt 1 (5) User 1 10:02pm Attempt 2 (4) User 1 10:04pm Attempt 3 (3) User 1 10:06pm Attempt 4 (2) User 1 10:07pm Attempt 5 (1) User 2 10:15pm Attempt 1 (2) User 2 10:20pm Attempt 2 (1) As you can see, all the attempts will increment (the numbers in the bracket) but the latest attempt will be set to one. How do I get it so that all the attempts are incremented so it looks like this. User - Time - Attempt- count() User 1 10:00pm Attempt 1 (5) User 1 10:02pm Attempt 2 (5) User 1 10:04pm Attempt 3 (5) User 1 10:06pm Attempt 4 (5) User 1 10:07pm Attempt 5 (5) User 2 10:15pm Attempt 1 (2) User 2 10:20pm Attempt 2 (2) Here is a snippet of my code: if (!$pw_ok) { if (isset($_SERVER["REMOTE_ADDR"])) { $str_RemoteHost = $_SERVER["REMOTE_ADDR"]; } else { $str_RemoteHost = ''; } $qry_WriteToDatabase = " INSERT INTO cms_user_login_attempts ( cula_user_id, cula_date_time, cula_remote_host, cula_attempt_count ) VALUES ( " . $db->SQLString($row->user_id) . ", Now(), " . $db->SQLString($str_RemoteHost, true) . ", 'cula_attempt_count' )"; $db->query($qry_WriteToDatabase); $qry_UpdateCount = " UPDATE cms_user_login_attempts SET cula_attempt_count = cula_attempt_count + 1 WHERE cula_user_id = " . $db->SQLString($row->user_id) . " "; $db->query($qry_UpdateCount); $qry_CheckDatabase = " SELECT CASE WHEN count(*) >= 5 THEN 0 ELSE 1 END as allowed_login FROM cms_user_login_attempts WHERE cula_date_time >= DATE_SUB(CURRENT_TIMESTAMP, interval 48 hour) AND cula_user_id = " . $db->SQLString($row->user_id) . ""; $rs_CheckDatabase = $db->query($qry_CheckDatabase); if (! (isset($qry_CheckDatabase) && $qry_CheckDatabase)) { $errors->defineError("invalid_user_pass", "Too many attempts, account locked for 48hours.", array("username","password")); } }
  20. I have just recently began learning PHP. I have a pretty solid foundation in general programming and PHP. As my first major PHP project I am trying to make myself an autobuyer for Fifa 15 using curt2008 Fifa API. He basically has everything there for me to use and I know that I have enough knowkledge to get a basic autobuyer going if I could just figure out how to log in. I have come to realize that the problem is that I have no idea what he is doing when he connects to the Fifa Web App. He has the code there for me, but I don't know what it is actually doing. I was hoping someone can point me to some documentation, a tutorial, or even exercises so that I may learn more about... logining into a web application? I don't even know what to call it. Looking at connect.php he has a bunch of functions. Login, getSessionID, Phishing, getNucleusID, getShards, and all of them do a bunch a requests and use a bunch of headers. I don't know what this terminology is or how it all works together, but I would like to learn about it. Thats why I wanted to start learning PHP, for stuff like this. I just don't know where to look. Thank You
  21. If you are using Vertabelo for creating database models and you access your database with Propel library, you'll find the following instructions useful. Vertabelo is an online, free tool for visual database design. Once you create a model of your database in Vertabelo, you can generate a Propel schema file from it. To do this you'll have to use VertabeloPropel, a PHP script which converts a Vertabelo XML file into Propel's schema.xml file. The script is available on GitHub. Installing VertabeloPropel uses Composer to manage project dependencies. In your project directory create a file composer.json: { "require": { "vertabelo/vertabelo-propel": "*" } } Then run Composer install. composer install This will download VertabeloPropel into the vendor directory in your project directory. The script will be in vendor/bin/vertabelo-propel.php file or, for Windows, in vendor\bin\vertabelo-propel.php.bat. Using VertabeloPropel script 1. Create a database model with Vertabelo. 2. Download the model as an XML file and save it in your project directory (use an option "Export model as XML file" from Vertabelo's tool bar). 3. Generate Propel's schema.xml file. If you want to use the default settings (input file model.xml, output file schema.xml, database name test, default id method native), run in Windows vendor\bin\vertabelo-propel.php.bat in Mac/Linux vendor/bin/vertabelo-propel.php If you want to change the defaults, run in Windows vendor\bin\vertabelo-propel.php.bat -i model.xml -o schema.xml / --database-name bookshop ---default-id-method native in Mac/Linux vendor/bin/vertabelo-propel.php -i model.xml -o schema.xml --database-name bookshop --default-id-method native 4. The script generates Propel's schema.xml file. 5. Proceed with your normal Propel application development (or see "How to develop a PHP+MySQL application with Propel and Vertabelo"). Script options The script options are: --input-file (shortcut -i) location of Vertabelo XML file (default value "model.xml") --output-file (shortcut -o) location of output Propel schema.xml file (default value "schema.xml") --database-name name of the database (default value "test") --default-id-method database's defaultIdMethod. Allowed values are “native” or “none”, default value is "native". --help prints the help message --------------- The above information was originaly published on Vertabelo's blog.
  22. This is posting to any row in mssql that has a matching 'start_date'. I would like it to post rows where start_date = '$start_date' and it also matches the 'meter_id' . It should perform this check of both parameters before posting to mssql. <?php $session_id = $_SESSION['id']; $comm_id = $_GET['meter_id']; $start_date = $_GET['start_date']; $payment_date = $_POST['payment_date']; $amount_paid = $_POST['amount_paid']; $check_number = $_POST['check_number']; $sql = "UPDATE [radiogates].[dbo].[ops_invoice_history] SET payment_date = '$payment_date', amount_paid = '$amount_paid', check_number = '$check_number' where start_date = '$start_date'"; $query = sqlsrv_query($conn, $sql); Thank you for any help.
  23. So I have a simple query that adds a text record into a MySQL database table. It works great with exception of one thing. I noticed that if I have "&" symbol in my paragraph, the text after that symbol won't be inserted into the table. The text before that symbol will insert fine. It seems to be doing that only with & symbol; other symbols insert and show up fine. can anyone tell me why this is happening?
  24. hello dear PHP-experts i run opensuse 13.2 i ve set up an apache webserver - well - if i type localhost into the browser then i see: it works but i want to see also phpmyadmin: the phpmyadmin on apache server - installed but not visible - what can i do now. I think that i have to check the running services on the machine!!? Which test can be done - with the terminal ? Which tests can i run on commandline ? love to hear from you greetings
  25. Hi, Just wondered if anyone can help? A contact form which has previously worked has stopped working, I presume because the PHP has been upgraded to version 5.6. If anyone is able to advise on how I need to tweak it, it would be massively appreciated! Code below: Thanks, Sarah <? // edit these lines $your_name="Company Name"; $your_email="sarah@companyname.co.uk"; $your_web_site_name="companyname.co.uk"; ?> <?php //If the form is submitted if(isset($_POST['name'])) { //Check to make sure that the name field is not empty if(trim($_POST['name']) === '') { $nameError = 'Please enter your name.'; $hasError = true; } else { $name = trim($_POST['name']); } //Check to make sure sure that a valid email address is submitted if(trim($_POST['email']) === '') { $emailError = 'Please enter your email address.'; $hasError = true; } else if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", trim($_POST['email']))) { $emailError = 'You entered an invalid email address.'; $hasError = true; } else { $email = trim($_POST['email']); } //Check to make sure comments were entered if(trim($_POST['message']) === '') { $commentError = 'Please enter your message.'; $hasError = true; } else { if(function_exists('stripslashes')) { $comments = stripslashes(trim($_POST['message'])); } else { $comments = trim($_POST['message']); } } //If there is no error, send the email if(!isset($hasError)) { $emailTo = $your_email; $subject = 'Contact Form Submission from '.$name; $body = "Name: $name \n\nEmail: $email \n\nPhone: ".trim($_POST['phone'])." \n\nComments: $comments"; $headers = 'From: '.$your_web_site_name.' <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email; mail($emailTo, $subject, $body, $headers); $emailSent = true; } } ?> <?php if(isset($emailSent) == true) { ?> <div class="ok"> <h1>Thanks, <?php echo $name;?></h1> <p>Your email was successfully sent. We will be in touch soon.</p> </div> <?php } ?> <?php if(isset($hasError) ) { ?> <div class="error2">There was an error submitting the form.</div> <?php } ?>
×
×
  • 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.