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. 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?
  2. 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.
  3. Hey all, Ive been lately dealing with a problem how to properly detect c function declarations in .h file (which is C99 standard) and save its info .... Suppose we have a .h file consisting of 3 lines: struct SymbolTable; void initContext(Context *pt); (<----- function 1) void deleteContext(Context *pt); i need a regular expresions to detect those function declarations and possibly save its info accordingly to this: $function1type == void $function1name == initContext $function1params == Context *pt Is it possible? Ive been struggling a lot with this but cant get it to work... In a .h file i have already removed blocs and macros and comments...
  4. I am new in php programming and I have develop php script using TCPDF libary that takes data from pdf form fields and create flatten copy of that PDF using TCPDF , after that I use "AttachMailer.php" to send copies of PDF to client and customer, when user fill pdf form and click submit button flatten copy of that pdf is created in wp-content/uploads/pdf folder , and email code gets same copy fro wp-content/uploads/pdf folder and copy is forwarded to client and customer once copies are forwarded, it should show message "email has been sent.....email-address". // =============Email Form=============================== require_once(dirname(__FILE__)."/AttachMailer.php"); $mailer = new AttachMailer($Email, $Email, "Submitted Form Copy", "hello <b>Please Find the Attached Copy of form sumitted</b>"); $mailer->attachFile($fpath.$Contact_Name.'_'.$Email.$fID); $mailer1 = new AttachMailer($Email,$CEmail, "CC for client Submitted Form ", "hello <b>Please Find the Attached Copy of form sumitted by </b>".$Contact_Name); $mailer1->attachFile($fpath.$Contact_Name.'_'.$Email.$fID); if($mailer->send()) { echo "Email has been sent to ".$Email."\n and" ; } else{ echo "error in email\n"; exit(); } if($mailer1->send()){ echo "\nCC has been sent to ".$CEmail ; } else{echo "\nerror in email CC was not sent to ".$CEmail;}! the problem is that when user click submit button he/or she is redirected to home page (which i dont want)with executing if and else statements in email code shown above please help me how can I stop redirecting to home page. you can see screenshot of redirected page from my dropbox https://www.dropbox.com/s/t48rqemujn21q42/redirectpagescreenshot.png?dl=0
  5. Hi, I have a table with the following data: id name hours annual_leave ================================= 1 Chris 10 0 2 Tony 15 0 3 Mark 9 0 4 John 23 0 5 Lee 8 0 What i want to achieve is: If an employee worked 10 hours or more then reward him/her with 1 day annual leave. By default the value of annual_leave is "0". So i find all eligible employees and store their IDs in a table: $eligible = array ( 0 => 1, 1=>2 , 2=>4); id name hours annual_leave ================================= 1 Chris 10 1 2 Tony 15 1 3 Mark 9 0 4 John 23 1 5 Lee 8 0 What i want to do is to create a single UPDATE query that will find all 3 employees and change the annual_leave value from 0 to 1. I can do this easily within the loop i use to create the $eligible table.. But i have the following questions: a) can i use a single UPDATE query to update multiple rows/columns in a table? b) what is better? a single query to update multiple rows/columns or multiple queries that update a single row/column per time c) can i combine PHP and MYSQL to syntax a query? because in case the $eligible array carries 1000 entries i will need to iterate through it using a FOR or WHILE loop.. Any other comments will be appreciated..
  6. 1down votefavorite I have been building a bowling score calculator. The calculator itself works but you must enter all scores in the form at once and then it will calculate the total score. I wanted it to loop form the form to enter your score for each frame, submit the form show the current score and reload the form again for the next frame. This is the first time I have used ajax and followed a tutorial on how to submit a form via ajax but it does not seem to be working. This is the first time I have used ajax, the ajax code is form an online tutorial I have followed and have not been able to get it working yet. The two scripts are below. PHP Script: <?php session_start(); //start a new game if (isset($_GET["endGame"]) && $_GET["endGame"] == 'yes') { session_destroy(); //redirect to homepage and remove any get parameters $location="http://localhost/bbc/v8.php"; echo '<META HTTP-EQUIV="refresh" CONTENT="0;URL='.$location.'">'; } //Check if the number of players has been set if (isset($_POST['next'])) { //Determine thye number players foreach ($_POST['numberOfPlayers'] as $player) { $_SESSION['numberOfPlayers'] = $player; $location="http://localhost/bbc/v8.php"; echo '<META HTTP-EQUIV="refresh" CONTENT="0;URL='.$location.'">'; } //check number of players has been set before enter player names } elseif (isset($_SESSION['numberOfPlayers'])) { $numberOfPlayers = $_SESSION['numberOfPlayers']; if (!isset($_POST['playerSubmit']) || (isset($_POST['scores']))) { ?> <!-- Form to enter the playes names --> <form method="post" action=""> <fieldset> <?php $x = 1; echo '<div class="custTitle"><h3>Enter player names below</h3></div>'; while ($x <= $numberOfPlayers) { echo '<input class="form-control" type="text" name="players[]" placeholder="Player ' . $x . '">'; $x++; } ?> </fieldset> <input type="submit" name="playerSubmit" value="Start Game"> </form> <?php }// close if } if (isset($_POST['playerSubmit'])) { $players = array(); foreach ($_POST['players'] as $player) { $players[] = $player; } // save player names array to session for reuse $_SESSION['players'] = $players; } //Check player name have been submitted if(isset($_POST['playerSubmit']) || isset($_SESSION['players'])) { //create global variable of players array $players = $_SESSION['players']; $_SESSION['frameScore'] = array(0); $frameCount = 1; while ($frameCount <=9 ) { ?> <!-- Form to enter players score--> <form method="post" action="" class="ajax"> <?php $i = 0; while($i < $_SESSION['numberOfPlayers']){ echo '<fieldset>'; echo '<h3>' . $players[$i] . '</h3>'; $x=1; // loop the form 21 times for maximum of 21 throws while($x <= 3){ ?> <label>Throw, <?php echo $x; ?></label> <select class="form-control" name="score[<?php echo $i; ?>][<?php echo $x; ?>]"> <option value="0">0</option> <option value="1">1</option> <option value="2">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">X</option> </select> <?php $x++; }// close 21 throws while ?> <input type="hidden" name="player[<?php echo $i; ?>]" value="<?php echo $players[$i] ?>"> </fieldset> <?php $i++; }// close while for looping throuhg players ?> <input type="submit" value="Finish Game" name="scores"/> </form> <?php // close player submit if // check if any scores have been submitted if(isset($_POST['score'])) { $i = 0; $result = []; foreach($_SESSION['players'] as $name) { $result[$name] = $_POST['score'][$i]; $pins = $_POST['score'][$i]; $game = calculateScore($i, $pins); $i++; } } $frameCount++; }// close do while // if number of players is not yet set the show the form to select number of players } else { ?> <!-- Form to select the number players --> <h2>How many players will be bowling?</h2> <form method="post" action=""> <select class="form-control" name="numberOfPlayers[]"> <option name="numberOfPlayers[]" value="1">1</option> <option name="numberOfPlayers[]" value="2">2</option> <option name="numberOfPlayers[]" value="3">3</option> <option name="numberOfPlayers[]" value="4">4</option> <option name="numberOfPlayers[]" value="5">5</option> <option name="numberOfPlayers[]" value="6">6</option> </select> <input type="submit" name="next" value="Next"> </form> <?php }// close else // if the number of players has been set show a 'New Game' button if (isset($_SESSION['numberOfPlayers'])) { echo '<button class="btn_lrg"><span><a href="http://localhost/bbc/v8.php?endGame=yes">New Game</a></span></button>'; } // function to calculate the players scores function calculateScore($player, $pins) { global $players; $frame = 0; // create an array for the frame score //$frameScore = $_SESSION['frameScore']; //$frameScore = array(0); //loop for 10 frames of a game while ($frame <=9) { $_SESSION['frameScore'][$frame] = array_shift($pins); //Check for a strike if($_SESSION['frameScore'][$frame] == 10) { $_SESSION['frameScore'][$frame] = (10 + $pins[0] + $pins[1]); // No strike, so take in two throws } else { $_SESSION['frameScore'][$frame] = $_SESSION['frameScore'][$frame] + array_shift($pins); //Check for a spare if($_SESSION['frameScore'][$frame] == 10) { $_SESSION['frameScore'][$frame] = (10 + $pins[0]); } }// close if //Move to the next frame and loop again $frame++; }// close while //echo out player scoreborad echo '<h3>' .$_SESSION["players"][$player]. '</h3>' . '<h4>' . array_sum($_SESSION['frameScore']) . '</h4>'; }// end calculateScore function ?> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script src="main.js"></script> <!-- End Bowling Calculator Script --> JavaScript/Ajax: $('form.ajax').on('submit', function() { var that = $(this), url = that.attr('action'), type = that.attr('method'), data = {}; that.find('[name]').each(function(index, value) { var that = $(this), name = that.attr('name'), value = that.val(); data[name] = value; }); $.ajax({ url: url, type: type, data: data, }); return false; });
  7. 1down votefavorite I'm new to Yii, and I'm getting this error "Class 'app\controllers\CActiveDataProvider' not found" while running a widget. This is my code: models/industrial.php: <?php namespace app\models; use yii\db\ActiveRecord; class Industrial extends ActiveRecord { } controllers/IndustrialController.php: <?php namespace app\controllers; use yii\web\Controller; use yii\data\Pagination; use app\models\industrial; class IndustrialController extends Controller { public function actionIndex() { $dataProvider=new CActiveDataProvider('Industrial', array( 'pagination'=>array( 'pageSize'=>20, ), )); $query = industrial::find(); $pagination = new Pagination([ 'defaultPageSize' => 20, 'totalCount' => $query->count(), ]); $industrials = $query->orderBy('Company_Name') ->offset($pagination->offset) ->limit($pagination->limit) ->all(); return $this->render('index', [ 'industrials' => $industrials, 'pagination' => $pagination, 'dataProvider'=>$dataProvider, ]); } } views/industrial/index.php: <?php use yii\helpers\Html; use yii\widgets\LinkPager; ?> <h1>Industrial Companies</h1> <ul> <?php use kartik\export\ExportMenu; use kartik\grid\GridView; $gridColumns = [ ['class' => 'yii\grid\SerialColumn'], 'id', 'name', [ 'attribute'=>'Name', 'label'=>'Name', 'vAlign'=>'middle', 'width'=>'190px', 'value'=>function ($model, $key, $index, $widget) { return Html::a($model->Name, '#', []); }, 'format'=>'raw' ], 'Name', 'Location', 'Telephone', ]; echo ExportMenu::widget([ 'dataProvider' => $dataProvider, 'columns' => $gridColumns, 'fontAwesome' => true, 'dropdownOptions' => [ 'label' => 'Export All', 'class' => 'btn btn-default' ] ]) . "<hr>\n". GridView::widget([ 'dataProvider' => $dataProvider, 'columns' => $gridColumns, 'export' => [ 'fontAwesome' => true, ] ]); $array = (array) $industrials; function build_table($array){ // start table $html = '<table class="altrowstable" id="alternatecolor">'; // header row $html .= '<tr>'; foreach($array[0] as $key=>$value){ $html .= '<th>' . $key . '</th>'; } $html .= '</tr>'; // data rows foreach( $array as $key=>$value){ $html .= '<tr>'; foreach($value as $key2=>$value2){ $html .= '<td>' . $value2 . '</td>'; } $html .= '</tr>'; } // finish table and return it $html .= '</table>'; return $html; } echo build_table($array); ?> <?= LinkPager::widget(['pagination' => $pagination]) ?> I'm getting this error in IndustrialController at $dataProvider=new CActiveDataProvider('Industrial', array( 'pagination'=>array( 'pageSize'=>20, ), )); What is the problem here? Could you please help me?
  8. I am developing a database application using Yii Framework. I am reading tables from MySQL database and displaying them to the user. I need the user to be able to filter the fields in the table or search for a certain value. For example, I have a table named "supermarkets": CREATE TABLE IF NOT EXISTS `supermarkets` ( `name` varchar(71) NOT NULL, `location` varchar(191) DEFAULT NULL, `telephone` varchar(68) DEFAULT NULL, `fax` varchar(29) DEFAULT NULL, `website` varchar(24) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; .../model/supermarkets: <?php namespace app\models; use yii\db\ActiveRecord; class Supermarkets extends ActiveRecord { } .../views/supermarkets/index.php: <?php use yii\helpers\Html; use yii\widgets\LinkPager; ?> <h1>Supermarkets</h1> <ul> <?php $array = (array) $supermarkets; function build_table($array){ // start table $html = '<table class="altrowstable" id="alternatecolor">'; // header row $html .= '<tr>'; foreach($array[0] as $key=>$value){ $html .= '<th>' . $key . '</th>'; } $html .= '</tr>'; // data rows foreach( $array as $key=>$value){ $html .= '<tr>'; foreach($value as $key2=>$value2){ $html .= '<td>' . $value2 . '</td>'; } $html .= '</tr>'; } // finish table and return it $html .= '</table>'; return $html; } echo build_table($array); ?> ....Controllers/SupermarketsController: <?php namespace app\controllers; use yii\web\Controller; use yii\data\Pagination; use app\models\Supermarkets; class SupermarketsController extends Controller { public function actionIndex() { $query = supermarkets::find(); $pagination = new Pagination([ 'defaultPageSize' => 20, 'totalCount' => $query->count(), ]); $supermarkets = $query->orderBy('Name') ->offset($pagination->offset) ->limit($pagination->limit) ->all(); return $this->render('index', [ 'supermarkets' => $supermarkets, 'pagination' => $pagination, ]); } } I need the user to be able to filter the table or search its fields by one or more attribute. I'm using Yii2, so CDbcriteria doesn't work. How can I do this?
  9. My website is currently undergoing construction. I am revising the entire site. I own a modeling agency and it consist of hundreds of models and each model has their own portfolio webpage. 80% of the webpages have the same layout (logo, disclosures etc...) the only thing that differs from all of these pages are the photos of the models and the model's names. How can I use just one webpage (as a template) and only change the photos of the models and names to minimize the webpages to my site? This will save me time because I really don't want to revise over 100 webpages for each model page. I know php is the way to go but I don't know where to start. Should I have a database of model photos? Also how would I tie the name and the description of the model to the each photo using php. If someone could give me an example using php code and description as to what I need to do to accomplish this task it would be greatly appreciated. I am currently learning php but I'm not by any means experienced. I spoke with several IT specialist and they all say it's fairly easy to accomplish this but I haven't gotten any information yet as to how to get it completed.
  10. Hello guys! For every word in a sentence or phrase how do i make the first letter for each word a capital letter. Expecting your response Thanks guys!
  11. Hi guys, i am creating my change password site for my website and i have some problems with the code... For some reason i have difficulties with the passwords being compared and replaced in the db after crypting them. I wanted this: Either get the current users password and compare it to the input value of $oldpass or compare the input value of $oldpass with the password stored in the database for the current user. After checking if the $oldpass and the password from the database match and IF they match then take the input value of $newpass and $repeatpass, compare them and if they match, then crypt() $newpass and update the database with the new password. I am not even sure if the passwords are even crypted. Also in the code i am comparing $oldpass with $_SESSION['password'] which is not the password from the db, i can't figure out how to call the password from the db. Thanks in advance! <?php include 'check_login_status.php'; $u=""; $oldpass=md5($_POST['oldpass']); //stripping both strings of white spaces $newpass = preg_replace('#[^a-z0-9]#i', '', $_POST['newpass']); $repeatpass = preg_replace('#[^a-z0-9]#i', '', $_POST['repeatpass']); //get the username from the header if(isset($_GET["u"])){ $u = preg_replace('#[^a-z0-9]#i', '', $_GET['u']); } else { header("location: compare_pass.php?u=".$_SESSION["username"]); exit(); } // Select the member from the users table $sql = "SELECT password FROM users WHERE username='$u' LIMIT 1"; mysqli_query($db_conx, $sql); $user_query = mysqli_query($db_conx, $sql); // Now make sure that user exists in the table $numrows = mysqli_num_rows($user_query); if($numrows < 1){ echo "That user does not exist or is not yet activated, press back"; exit(); } if ($oldpass == $_SESSION['password']) { echo "session and oldpass are matching"; } else { echo "Session and oldpass do not match!"; } $isOwner = "no"; //check if user is logged in owner of account if($u == $log_username && $user_ok == true){ $isOwner = "yes"; } $passhash = ""; if (isset($_POST["submit"]) && ($isOwner == "yes") && ($user_ok == true) && ($newpass == $repeatpass)) { $passhash = crypt_sha256("$newpass", "B-Pz=0%5mI~SAOcW0pMUdgKQh1_B7H6sbKAl+9~O98E9MBPrpGOtE65ro~8R"); $sql = "UPDATE users SET `password`='$passhash' WHERE username='$u' LIMIT 1"; } if (mysqli_query($db_conx, $sql)) { echo "Record updated successfully"; } else { echo "Error updating record: " . mysqli_error($db_conx); } ?> <h3>Create new password</h3> <form action="" method="post"> <div>Current Password</div> <input type="text" class="form-control" id="password" name="oldpass" > <div>New Password</div> <input type="text" class="form-control" id="password" name="newpass" > <div>Repeat Password</div> <input type="text" class="form-control" id="password" name="repeatpass" > <br /><br /> <input type="submit" name="submit" value="Submit"> <p id="status" ></p> </form><?php echo "{$oldpass}, {$_SESSION['password']}"; ?> <pre> <?php var_dump($_SESSION); var_dump($oldpass); var_dump($passhash); var_dump($newpass); var_dump($repeatpass); ?> </pre>
  12. else if (preg_match('BSD',$ua) || preg_match('FreeBSD',$ua) || preg_match('NetBSD',$ua)) { $browser['platform'] = "BSD"; Warning: preg_match(): Delimiter must not be alphanumeric or backslash in /Homepages/33/d183561635/htdocs/xtc.../includes/pt_counter.stats.php on line 76 Can anybody help for the correct code?
  13. Please Help me to solve my problem.. I'm having some difficulties in solving the issue please HELP me I have this code <div class="span5"> <?php $get_id = $_GET['org_id']; $oid = isset($_GET['org_id'])?$_GET['org_id']:""; $query_vote=mysql_query("select * from votes where position='President' and voters_id='$session_id'"); $count=mysql_num_rows($query_vote); $row=mysql_fetch_array($query_vote); $id=$row['vote_id']; if ($count==1){ ?> <script type="text/javascript"> jQuery(document).ready(function() { $('#delete<?php echo $id; ?>').tooltip('show'); $('#delete<?php echo $id; ?>').tooltip('hide'); }) </script> <h6>My Candidate for President</h6> <div class="none"><img class="img-polaroid" src="admin/<?php echo $row['img']; ?>" width="88" height="88"/> <a><?php echo $row['firstname']." ".$row['lastname']; ?></a> <a class="btn btn-danger" data-placement="right" id="delete<?php echo $id; ?>" title="Click to Remove" href="#<?php echo $id; ?>" data-toggle="modal"> <i class="icon-remove icon-large"> </i></a> <!---delete modal --> <?php include('delete_user_modal.php'); ?> <!---delete modal --> <?php }else{ ?> <h6>Candidate for President</h6> <?php $result = mysql_query("SELECT candidates.candidates_id, candidates.firstname, candidates.lastname, candidates.img FROM candidates INNER JOIN voters ON voters.org_id = candidates.org_id WHERE position='President' AND candidates_id='$get_id' "); while($row=mysql_fetch_assoc($result)) { $id=$row['candidates_id']; ?> <script type="text/javascript"> jQuery(document).ready(function() { $('#a<?php echo $id; ?>').tooltip('show'); $('#a<?php echo $id; ?>').tooltip('hide'); }) </script> <div class="picture"><img data-placement="bottom" id="a<?php echo $id; ?>" title="Drag the Image to the ballot Box to Vote for <?php echo $row['firstname']." ".$row['lastname']; ?>" class="img-polaroid" src="admin/<?php echo $row['img']; ?>" width="88" height="128"/> <br> <a><?php echo $row['firstname']." ".$row['lastname']; ?></a> </div> <?php } ?> <?php } ?> <div> But the problem is that im getting this error in my page Notice: Undefined index: org_id please help me and give me some advice on how to resolve this
  14. It is hard to explain the situation.. Better have a look at the attatchment.. run the sccript and add some mp3 file in music folder. now browse the script and you will find something like this Why the metadata only added in first file? Something Helpful: * id.php is used to extract metadata like Album, Artist etc. * Line 168-177 is the loop for mp3 file. * I on't nee to show metadata in download page. I only want to show metadata of every file on the loop.
  15. Good Day, Please help me to create a simple organisation management in php so this is the scenario, i have 3 tables (organisation, student, teacher) the simple system works fine But the problem is that adding organisation to my system. ? because before i just type it in my query WHERE org_name = 'COMTECH' to my students query and to my index query after i log in as a student how can i add organisation and create a log in that connects the student on the organisation that he is registered ? So this the example data in my database table Organisation.tbl org_id: 1 org_name: COMTECH org_description: computer fundamentals Student.tbl Teacher.tbl student_id: 1 teacher_id: 1 username: student username: teacher password: demo password: demo firstname: alvin user_type: Admin lastname: biares So right no im having hard time to solve the problem that if the organisation was created and the students are registered to that organisation the student can see only the teachers who are already registered in that organisation. ? please help me..
  16. hello dear php-experts, the question of the day - how to find a file with a certain text - the commands below do not help here .... the are good but they do not open the file find . | xargs grep "texthere" * grep -r "texthere" . grep -r "a target="_blank"" find ./ -type f | xargs grep "foo" hmm - well i guess that the grep command will help here. well i want to do a seach recursively - through all files in a folder. And i want to open fhe file - after it is found. How can we do this!? love to hear from you
  17. Hi, I have a PHP script sendEmail.php that given some data (receiver, content, etc), sends an email to the receiver. When i click the Send button i fire the sendEmail.php script using AJAX: $('#sendbutton').on('click', function(){ $.ajax({ type: "POST", url: "js/ajax/sendEmail.php", data: {receiver:receiver, content: content} }); }); I want to add a feature call "Schedule send" where the user can select in how many minutes the email will be send. What i did, was to take the minutes value, insert it into a countDown timer, and as soon as the time is Zero, to fire the same AJAX call. This is working only if the browser is open. And i can understand this, since it is Javascript's responsibility to fire the AJAX call since its the one on client site. QUESTION: Is there a way to fire this sendEmail.php scipt even if the web browser is closed?Using PHP/MYSQL of course.. For example the user will select the recipient, write the email, schedule it to be sent 20 minutes later, and close the browser. If not, what are your suggestions? Thanks in advance, Christos
  18. I am trying to create a dynamic form using Jquery but don't know how to post those data using $_POST. The page <html> <head> <title> Dynamically create input fields- jQuery </title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script> <script type="text/javascript"> $(function() { var addDiv = $('#addinput'); var i = $('#addinput p').size() + 1; $('#addNew').live('click', function() { $('<p><input type="text" id="p_new" size="40" name="p_new_' + i +'" value="" placeholder="I am New" /><input type="text" id="p_new2" size="40" name="p_new_2' + i +'" value="" placeholder="I am New 2" /><a href="#" id="remNew">Remove</a> </p>').appendTo(addDiv); i++; return false; }); $('#remNew').live('click', function() { if( i > 2 ) { $(this).parents('p').remove(); i--; } return false; }); }); </script> </head> <body> <h2>Dynammically Add Another Input Box</h2> <form action="gen.php" method="post"> <div id="addinput"> <p> <input type="text" id="p_new" size="40" name="p_new" value="" placeholder="Input Value" /><input type="text" id="p_new2" size="40" name="p_new2" value="" placeholder="Input Value" /><a href="#" id="addNew">Add</a> </p> </div> </form> </body> </html> Here is live example.. A Pen by Captain Anonymous Whatever, The new fields got an unique name="" value as p_new_1, p_new_21 for first new field, p_new_2, p_new_22 for second new field ...... ...... Now, I know I can display inserted data using <?php echo $_POST["p_new_1"]; ?> and similar way like this... But as a growing field, this form can have unlimited input field. How can I display all of those data in the page gen.php? It must be something like this example: <html> <body> <div class="header">Generated content<div> <p><a href="inserted data of first field of default row">inserted data of second field of default row</a></p> <p><a href="inserted data of first field of first new row">inserted data of second field of first new row</a></p> <p><a href="inserted data of first field of 2nd new row">inserted data of second field of 2nd new row</a></p> <p><a href="inserted data of first field of 3rd new row">inserted data of second field of 3rd new row</a></p> <p><a href="inserted data of first field of 4th new row">inserted data of second field of 4th new row</a></p> And list go on according to submitted form.... </div></body></html> I actually lake of knowledge of PHP and no idea about array or something named loop. Can someone do it for me? What I have to do in gen.php?
  19. Hello guys! I really really really hope anyone can help me because I am quite desperate about a little project I'm making. I want to construct a sort of online catalog for books with a "shoppingcart" and a profile for every user, but object orientated. I have a database with the table products which contains: ID, title, author, genre, price etc etc etc My main question is: How can I get one single field from the database with e.g. a function called getPrice(); I tried everything but nothing displays the data the way i want to. I simply want to have a sql-statement in this function and when I am calling the function getPrice() later on it displays just the number and no Array, code or whatever. Is there a way to call getPrice() and get "20.00" back? Please Help!
  20. I am creating a word scramble game in PHP .But I am having difficulty in doing it. What Iam planning to do is to get the jumbled words from the database and display it as tile format or individual buttons . The words are scrambled and I have to do dragging it so that it matched the word from mysql. First how to get individual letters from mysql and that too scrambled. Individual letters , I know it is str_split($words) so that the letter is split into letters. Please help me on this.
  21. Hello I am a desktop / database programmer. I wish to write a program to read data from a database and populate a combobox in an html page. I have read that PHP can do this. Is this correct? I would prefer not to have to use a web server since this is a local app and there will be one page and it will be static excpet for a few selection criteria (like a combobox). All the examples I see are for web pages. If this can be done can someone point me in the right direction? Thanks JM
  22. Hello, So I need to convert PHP code to JSP/Java. I really don't understand PHP and would like an explanation as to what this code is doing. So I can convert it, any help would be great thank you it's only 4 lines of code sitemap.php Attached PHP file
  23. Hi; I'm writing a php script which is about advertising.I created a table and i wanted to get informations from the column which is in the table , is named "tema".For example ; i created a table which is called "ilan" ; and in the table i created a column which is named "tema" i got the information from the MYSQL "tema='tehnika'" everything is allright till this moment after this when i opened my php file i couldnt see the ROW which is "tema='tehnika'" in the index although i got to one row .. When i look the sources of my index i see that PHP got allrows and also when i search the browser other rows browser can find but it doesnt show where these words are located :S first i think maybe something wrong with my CSS properties. but it is not about CSS so where is the wrong ? ???? This is my source codes: <?php require_once('baglan.php');//i connected to Database// if($db->connect_errno) die("Veritabanına bağlanılamıyor.".$db->connect_error()); $db->set_charset("utf-8"); $toplam=$db->prepare("SELECT count(*) FROM ilanlar WHERE tema='tehnika'"); $toplam->execute(); $sayfa_sayisi=$toplam->get_result(); $sayfacik=$sayfa_sayisi->fetch_row(); $toplam->close(); $sql=$db->prepare("SELECT * FROM ilanlar WHERE tema='tehnika' Order By id DESC LIMIT ? OFFSET ?"); $limit=4; $offset=isset($_GET["id"]) ? $_GET["id"] : 0 ; $sql->bind_param("ii",$limit,$offset); $sql->execute(); $sql_sonuc=$sql->get_result(); while($row=$sql_sonuc->fetch_array()) { echo "<div id='ilanlar'> <h1><img src='yuklemeler/{$row["fotoadi"]}'><a href=detay.php?id={$row["id"]}>{$row["konu"]}</a></h1> <p><h3>{$row["tarih"]}</h3></p> <br/></div> "; } if($sayfacik[0]>$limit) { $x = 0 ; for($i = 0 ; $i<$sayfacik[0];$i+=$limit) { $x++; } } $db->close(); ?> http://i57.tinypic.com/2ccow9x.png
  24. So this is the scenario, i have 3 tables in my database voters.tbl, candidates.tbl, organisation.tbl so if the voters registered by the organisation and the candidates registered in the same organisation like the voters. The user/Voters must see only the candidates that has the same id of a voter. Let's say ORGANISATION.TBL ---------------------- CANDIDATES.TBL org_id: 1 ------------------- org_name: umbrella candidates_id: 1 firstname: ramon lastname: mclights org_id: 1 VOTERS.TBL ------------------ voters_id: 1 firsname: Anne lastname: Sunga org_id: 1 The bold text are the value of the column Please help me here how can i Query and compares the id of candidates and voters
  25. I am brand new to php and MySQL. I am working on a small project and I am getting this error and I cannot find the reason why. Can someone please help. The error is Warning: mysqli_stmt::bind_result(): Number of bind variables doesn't match number of fields in prepared statement in C:\xampp\htdocs\test\records.php on line 134 <?php /* Allows the user to both create new records and edit existing records */ // connect to the database include("connect-db.php"); // creates the new/edit record form // since this form is used multiple times in this file, I have made it a function that is easily reusable function renderForm($first = '', $middle = '', $last = '', $ClientID = '', $Diagnosis = '', $Gender = '', $LevelCare = '', $Counselor = '', $error = '', $id = '') { ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title> <?php if ($id != '') { echo "Edit Record"; } else { echo "New Record"; } ?> </title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> </head> <body> <h1><?php if ($id != '') { echo "Edit Record"; } else { echo "New Record"; } ?></h1> <?php if ($error != '') { echo "<div style='padding:4px; border:1px solid red; color:red'>" . $error . "</div>"; } ?> <form action="" method="post"> <div> <?php if ($id != '') { ?> <input type="hidden" name="id" value="<?php echo $id; ?>" /> <p>id: <?php echo $id; ?></p> <?php } ?> <strong>First Name: *</strong> <input type="text" name="FirstName" value="<?php echo $first; ?>"/><br/> <strong>Middle Name: </strong> <input type="text" name="MiddleName" value="<?php echo $middle; ?>"/> <strong>Last Name: *</strong> <input type="text" name="LastName" value="<?php echo $last; ?>"/> <strong>Client ID: *</strong> <input type="text" name="ClientID" value="<?php echo $ClientID; ?>"/> <strong>Diagnosis: *</strong> <input type="text" name="Diagnosis" value="<?php echo $Diagnosis; ?>"/> <strong>Gender: *</strong> <input type="text" name="Gender" value="<?php echo $Gender; ?>"/> <strong>Level <span class="posthilit">of</span> Care: *</strong> <input type="text" name="LevelCare" value="<?php echo $LevelCare; ?>"/> <strong>Counselor: *</strong> <input type="text" name="Counselor" value="<?php echo $Counselor; ?>"/> <p>* required</p> <input type="submit" name="submit" value="Submit" /> </div> </form> </body> </html> <?php } /* EDIT RECORD */ // if the 'id' variable is set in the URL, we know that we need to edit a record if (isset($_GET['id'])) { // if the form's submit button is clicked, we need to process the form if (isset($_POST['submit'])) { // make sure the 'id' in the URL is valid if (is_numeric($_POST['id'])) { // get <span class="posthilit">variables</span> from the URL/form $id = $_POST['id']; $FirstName = htmlentities($_POST['FirstName'], ENT_QUOTES); $MiddleName = htmlentities($_POST['MiddleName'], ENT_QUOTES); $LastName = htmlentities($_POST['LastName'], ENT_QUOTES); $ClientID = htmlentities($_POST['ClientID'], ENT_QUOTES); $Diagnosis = htmlentities($_POST['Diagnosis'], ENT_QUOTES); $Gender = htmlentities($_POST['Gender'], ENT_QUOTES); $LevelCare = htmlentities($_POST['LevelCare'], ENT_QUOTES); $Counselor = htmlentities($_POST['Counselor'], ENT_QUOTES); // check that FirstName, LastName and ClientID are not empty if ($FirstName == '' || $MiddleName == '' || $LastName == '' || $ClientID == '' || $Diagnosis == '' || $Gender == '' || $LevelCare == '' || $Counselor == '') { // if they are empty, show an error message and display the form $error = 'ERROR: Please fill in all required fields!'; renderForm($FirstName, $MiddleName, $LastName, $ClientID, $Diagnosis, $Gender, $LevelCare, $Counselor, $error, $id); } else { // if everything is fine, update the record in the database if ($stmt = $mysqli->prepare("UPDATE clients SET FirstName = ?, MiddleName = ?, LastName = ?, ClientID = ?, Diagnosis = ?, Gender = ?, LevelCare = ?, Counselor = ? WHERE id=?")) { $stmt->bind_param("ssssssssi", $FirstName, $MiddleName, $LastName, $ClientID, $Diagnosis, $Gender, $LevelCare, $Counselor, $id); $stmt->execute(); $stmt->close(); } // show an error message if the query has an error else { echo "ERROR: could not prepare SQL statement."; } // redirect the user once the form is updated header("Location: view-paginated.php"); } } // if the 'id' variable is not valid, show an error message else { echo "Error!"; } } // if the form hasn't been submitted yet, get the info from the database and show the form else { // make sure the 'id' value is valid if (is_numeric($_GET['id']) && $_GET['id'] > 0) { // get 'id' from URL $id = $_GET['id']; // get the record from the database if($stmt = $mysqli->prepare("SELECT * FROM clients WHERE id=?")) { $stmt->bind_param("i", $id); $stmt->execute(); $stmt->bind_result($id, $FirstName, $MiddleName, $LastName, $ClientID, $Diagnosis, $Gender, $LevelCare, $Counselor); $stmt->fetch(); // show the form renderForm($FirstName, $MiddleName, $LastName, $ClientID, $Diagnosis, $Gender, $LevelCare, $Counselor, NULL, $id); $stmt->close(); } // show an error if the query has an error else { echo "Error: could not prepare SQL statement"; } } // if the 'id' value is not valid, redirect the user back to the view.php page else { header("Location: view.php"); } } } /* NEW RECORD */ // if the 'id' variable is not set in the URL, we must be creating a new record else { // if the form's submit button is clicked, we need to process the form if (isset($_POST['submit'])) { // get the form data $FirstName = htmlentities($_POST['FirstName'], ENT_QUOTES); $MiddleName = htmlentities($_POST['MiddleName'], ENT_QUOTES); $LastName = htmlentities($_POST['LastName'], ENT_QUOTES); $ClientID = htmlentities($_POST['ClientID'], ENT_QUOTES); $Diagnosis = htmlentities($_POST['Diagnosis'], ENT_QUOTES); $Gender = htmlentities($_POST['Gender'], ENT_QUOTES); $LevelCare = htmlentities($_POST['LevelCare'], ENT_QUOTES); $Counselor = htmlentities($_POST['Counselor'], ENT_QUOTES); // check that FirstName and LastName are both not empty if ($FirstName == '' || $MiddleName == '' || $LastName == '' || $ClientID == '') { // if they are empty, show an error message and display the form $error = 'ERROR: Please fill in all required fields!'; renderForm($FirstName, $MiddleName, $LastName, $ClientID, $Diagnosis, $Gender, $LevelCare, $LevelCare, $Counselor, $error); } else { // insert the new record into the database if ($stmt = $mysqli->prepare("INSERT clients (FirstName, MiddleName, LastName, ClientID, Diagnosis, Gender, LevelCare, Counselor) VALUES (?, ?, ?, ?, ?, ?, ?, ?)")) { $stmt->bind_param("ssssssss", $FirstName, $MiddleName, $LastName, $ClientID, $Diagnosis, $Gender, $LevelCare, $Counselor); $stmt->execute(); $stmt->close(); } // show an error if the query has an error else { echo "ERROR: Could not prepare SQL statement."; } // redirec the user header("Location: view.php"); } } // if the form hasn't been submitted yet, show the form else { renderForm(); } } // close the mysqli connection $mysqli->close(); ?>
×
×
  • 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.