PHP - Extending Crm User Functionality
I am working on a REST application which is intended to be used with various CMS’s (Drupal, WordPress, etc). Each CMS installation passes a unique GUID in the header to identify the organization so that the organization's individual data is utilized. I’ve since realized I need some basic way to identify the individual user for at least two reasons: The API provides a help desk where individual users can ask questions and get responses (not real time). There is some need for user access/privileges (I suppose this could be CMS side if necessary).Instead of inputting users both into the API as well as the CMS, the organization should be responsible for entry only through the CMS. They will add users as appropriate for the given CMS and then another page on the CMS will list all the CMS users and provide a way to set whether they are authorized to access the API as well as their access level. The remaining of this post is kind of what I am thinking, but I am open to change. When the CMS gives a user access to the API for the first time, a cURL request is made to the API and a unique key is returned and the CMS will save it as being associated with the given user. Note sure if this should be an incrementing number on a per organization basis or another GUID, and if a GUID whether it should be passed along with the organization’s GUID or replace it. Also, not positive, but thinking that user data (name, email, etc) should not be given to the API as it might be difficult to keep them synchronized. If a user’s access level is changed on the CMS or their access is removed, the user’s GUID is passed to the API and the work is done on the API. If the user is removed, they are not deleted from the API’s database but just tagged as deleted. Before performing step 1, the CMS should first perform a query requesting all users who are tagged as deleted and is responsible to determine whether a new user should be added or an existing user should be reinstated. Alternatively, I can make the API responsible for doing so, but then it would need to have stored various data to identify whether the user was previously instated which might result in the synchronization issue I described in step 1.Any comments, potential pitfalls, or recommendations would be appreciated. Similar TutorialsIm having problem extending a class. Code: [Select] <?php // Parent class class Profile { protected $id, $result, $info; protected function get_id() { return $_GET['id']; } protected get_info() { $id = $this->get_id(); $result = mysql_query("SELECT * FROM profiles WHERE id = '$id' "); return mysql_fetch_array($result); } public get_fname() { $info = $this->get_info(); return $info['fname']; } public get_lname() { $info = $this->get_info(); return $info['lname']; } } // Child class class Profile_new extends Profile { protected get_info() { $id = $this->get_id(); $result = mysql_query("SELECT * FROM new_profiles WHERE id = '$id' "); return mysql_fetch_array($result); } } // Webpage $profile = new Profile_new; $first_name = $profile->get_fname(); $last_name = $profile->get_lname(); ?> For some reason I still getting first + last names of people from the profiles table, and not from the new_profiles table. How can I fix this ? This scripts works fine however I want to extend the if check against the database so that somehow instead of just telling the user that there was a problem on the on the form page I can tell them which was the actual problem so how could I extend it so that I can tell the user if it was the contentpage or the shortname that was the problem. if (isset($_POST['editcontentpage'])) { $contentpage = mysqli_real_escape_string($dbc, $_POST['contentpage']); $shortname = mysqli_real_escape_string($dbc, $_POST['shortname']); $contentcode = mysqli_real_escape_string($dbc, $_POST['contentcode']); $linebreak = mysqli_real_escape_string($dbc, $_POST['linebreak']); $backlink = mysqli_real_escape_string($dbc, $_POST['backlink']); $showheading = mysqli_real_escape_string($dbc, $_POST['showheading']); $visible = mysqli_real_escape_string($dbc, $_POST['visible']); $template = (int)$_POST['template']; $contentpageID = (int)$_POST['contentpageID']; $query = "SELECT * FROM `contentpages` WHERE `contentpage` = '".$contentpage."' OR `shortname` = '".$shortname."'"; $result = mysqli_query ( $dbc, $query ); // Run The Query $rows = mysqli_num_rows($result); if ($rows == 0) { $query = "UPDATE `contentpages` SET `contentpage` = '".$contentpage."', `shortname`='".$shortname."', `contentcode`='".$contentcode."', `linebreaks`='".$linebreak."', `backlink`='".$backlink."', `showheading`='".$showheading."', `visible`='".$visible."', `template_id`='".$template."' WHERE `id` = '".$contentpageID."'"; mysqli_query($dbc,$query); echo "good"; } else { echo "bad"; } } could anyone advice how to extend the php class who contains variable? sample below does not work. Code: [Select] class test1 extends test2($index){ public function output($index){ echo $index; } } class test2{ public function __construct($index){ echo $index; } } $test = new test1; $test->output('My Test2'); $test->test2('My Test1'); Hi Not sure if I am on the right track here but what I am trying to do is set a variable in the parent class and for this to be accessible in the child. class layout { public $site_id; function __construct($site_id) { $this->site_id = $site_id; } function get_flags() { return new flags($this); } function top_nav() { return new top_nav($this); } } class top_nav extends layout { function __construct(){ } function display_site_id() { echo $this->site_id; } } class flags extends layout { function __construct(){ } function display_site_id() { echo $this->site_id; } } $site_id = 1; $layout = new layout($site_id); $flags = $layout->get_flags(); $nav = $layout->top_nav(); var_dump($layout); var_dump($flags); var_dump($nav); This gives me the following output object(layout)#1 (1) { ["site_id"]=> int(1) } object(flags)#2 (1) { ["site_id"]=> NULL } object(top_nav)#3 (1) { ["site_id"]=> NULL } Where I would have expected object(layout)#1 (1) { ["site_id"]=> int(1) } object(flags)#2 (1) { ["site_id"]=> int(1) } object(top_nav)#3 (1) { ["site_id"]=> int(1) } but I am new to OOP and might be doing things completely wrong Thanks for your help Regards Hi gents, This will be an easy one for you all! I have a sql select statement and everything functions fine as is, BUT I would like to give users more freedom. Using this sql statement the results only return if the user types the Botanical Name or Common Name of a particular plant exactly as it is spelled in the database: $sql = mysql_query("SELECT PlantID, CommonName FROM plants WHERE BotanicalName='$BotanicalName' OR CommonName='$CommonName' OR Use1='$Use' OR Use2='$Use' OR Use3='$Use' OR Use4='$Use' OR Use5='$Use' ORDER BY CommonName"); What if the user doesn't know the species of a plant and only it's genus or the user only knows Maple tree and not which particular one they are looking for: For example: Plant in Database = Brandywine Red Maple User Search would have to be exactly that "Brandywine Red Maple" for a result to return Ideally I would like the user to be able to type in "Maple" and ALL Maples return Let me know if you need more info hello, I am running php locally on my machine but it seems that when I try to call mail () function, I get error messages. I believe that I need to set up a mail server on my machine. Is that an accurate statement? whats the easiest way to do this? Is having OUTLOOK installed on the machine sufficient? I am a newbie trying to build a quiz system. I have all of the questions and answer choices in a mysql table. My code below selects the question and answers. They appear exactly how I want them to....but I'm stuck on the form functionality. I was trying to use something like this: Code: [Select] <input type='radio' name='Q1Choice' value='$answer1' /> I need to be able to insert the choice into my table. I know how to do the insert part but not sure how to take the radio choice as the insert data. Code: [Select] <? //Connect to database mysql_connect($host, $dbusername, $password); mysql_select_db($TxQuizdb); //Retrieve Quiz Questions $qquery = mysql_query("SELECT * FROM Module_1_Quiz"); while ($m1questions = mysql_fetch_array($qquery)) { echo "<table width=600 border=1><tr><td>"; echo $m1questions['Question']; echo "</td></tr><br><tr><td>"; echo $m1questions['Choice1']; echo "<br>"; echo $m1questions['Choice2']; echo "<br>"; echo $m1questions['Choice3']; echo "</td></tr></table>"; } thanks for any help. My code about filterable audio searching, here how can i add Add-To-Cart functionality?
code : <?php //index.php include('database_connection.php'); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="description" content=""> <meta name="author" content=""> <title>Voice Repository</title> <script src="js/jquery-1.10.2.min.js"></script> <script src="js/jquery-ui.js"></script> <script src="js/bootstrap.min.js"></script> <link rel="stylesheet" href="css/bootstrap.min.css"> <link href = "css/jquery-ui.css" rel = "stylesheet"> <!-- Custom CSS --> <link href="css/style.css" rel="stylesheet"> </head> <body> <!-- Page Content --> <div class="container"> <div class="row"> <br /> <div class="col-md-12"> <h2 align="center">Voice Repository Bank</h2> </div> <div class="col-md-3"> <!-- Price --> <!-- <div class="list-group"> <h3>Price</h3> <input type="hidden" id="hidden_minimum_price" value="0" /> <input type="hidden" id="hidden_maximum_price" value="65000" /> <p id="price_show">1000 - 65000</p> <div id="price_range"></div> </div> --> <!-- Languages --> <div class="list-group"> <h3>Languages</h3> <?php $query = " SELECT DISTINCT(voice_languages) FROM voice_bank_data WHERE voice_status = '1' ORDER BY voice_languages DESC "; $statement = $connect->prepare($query); $statement->execute(); $result = $statement->fetchAll(); foreach($result as $row) { ?> <div class="list-group-item checkbox"> <label><input type="checkbox" class="common_selector languages" value="<?php echo $row['voice_languages']; ?>" > <?php echo $row['voice_languages']; ?> </label> </div> <?php } ?> </div> <!-- Genres --> <div class="list-group"> <h3>Genres</h3> <?php $query = " SELECT DISTINCT(voice_genres) FROM voice_bank_data WHERE voice_status = '1' ORDER BY voice_genres DESC "; $statement = $connect->prepare($query); $statement->execute(); $result = $statement->fetchAll(); foreach($result as $row) { ?> <div class="list-group-item checkbox"> <label><input type="checkbox" class="common_selector genres" value="<?php echo $row['voice_genres']; ?>" > <?php echo $row['voice_genres']; ?> </label> </div> <?php } ?> </div> <!-- Voice Modulation --> <div class="list-group"> <h3>Voice Modulation</h3> <?php $query = " SELECT DISTINCT(voice_voice_modulation) FROM voice_bank_data WHERE voice_status = '1' ORDER BY voice_voice_modulation DESC "; $statement = $connect->prepare($query); $statement->execute(); $result = $statement->fetchAll(); foreach($result as $row) { ?> <div class="list-group-item checkbox"> <label><input type="checkbox" class="common_selector voice_modulation" value="<?php echo $row['voice_voice_modulation']; ?>" > <?php echo $row['voice_voice_modulation']; ?> </label> </div> <?php } ?> </div> <!-- Gender --> <div class="list-group"> <h3>Gender</h3> <div style="height: 180px; overflow-y: auto; overflow-x: hidden;"> <?php $query = "SELECT DISTINCT(voice_gender) FROM voice_bank_data WHERE voice_status = '1' ORDER BY voice_id DESC"; $statement = $connect->prepare($query); $statement->execute(); $result = $statement->fetchAll(); foreach($result as $row) { ?> <div class="list-group-item checkbox"> <label><input type="checkbox" class="common_selector gender" value="<?php echo $row['voice_gender']; ?>" > <?php echo $row['voice_gender']; ?></label> </div> <?php } ?> </div> </div> <!-- Jingle Moods --> <div class="list-group"> <h3>Jingle Moods</h3> <?php $query = " SELECT DISTINCT(voice_jingle_moods) FROM voice_bank_data WHERE voice_status = '1' ORDER BY voice_jingle_moods DESC "; $statement = $connect->prepare($query); $statement->execute(); $result = $statement->fetchAll(); foreach($result as $row) { ?> <div class="list-group-item checkbox"> <label><input type="checkbox" class="common_selector jingle_moods" value="<?php echo $row['voice_jingle_moods']; ?>" > <?php echo $row['voice_jingle_moods']; ?> </label> </div> <?php } ?> </div> <!-- IVR --> <div class="list-group"> <h3>Ivr</h3> <?php $query = " SELECT DISTINCT(voice_ivr) FROM voice_bank_data WHERE voice_status = '1' ORDER BY voice_ivr DESC "; $statement = $connect->prepare($query); $statement->execute(); $result = $statement->fetchAll(); foreach($result as $row) { ?> <div class="list-group-item checkbox"> <label><input type="checkbox" class="common_selector ivr" value="<?php echo $row['voice_ivr']; ?>" > <?php echo $row['voice_ivr']; ?> </label> </div> <?php } ?> </div> </div> <div class="col-md-9"> <br /> <div class="row filter_data"> </div> </div> </div> </div> <style> #loading { text-align:center; background: url('loader.gif') no-repeat center; height: 150px; } </style> <script> $(document).ready(function(){ filter_data(); function filter_data() { $('.filter_data').html('<div id="loading" style="" ></div>'); var action = 'fetch_data'; // var minimum_price = $('#hidden_minimum_price').val(); // var maximum_price = $('#hidden_maximum_price').val(); var gender = get_filter('gender'); var genres = get_filter('genres'); var voice_modulation = get_filter('voice_modulation'); var languages = get_filter('languages'); var jingle_moods = get_filter('jingle_moods'); var ivr = get_filter('ivr'); $.ajax({ url:"fetch_data.php", method:"POST", data: { action:action, // minimum_price:minimum_price, // maximum_price:maximum_price, gender:gender, genres:genres, voice_modulation:voice_modulation, languages:languages, jingle_moods:jingle_moods, ivr:ivr }, success:function(data) { $('.filter_data').html(data); } }); } function get_filter(class_name) { var filter = []; $('.'+class_name+':checked').each(function(){ filter.push($(this).val()); }); return filter; } $('.common_selector').click(function(){ filter_data(); }); // $('#price_range').slider({ // range:true, // min:1000, // max:65000, // values:[1000, 65000], // step:500, // stop:function(event, ui) // { // $('#price_show').html(ui.values[0] + ' - ' + ui.values[1]); // $('#hidden_minimum_price').val(ui.values[0]); // $('#hidden_maximum_price').val(ui.values[1]); // filter_data(); // } // }); }); </script> </body> </html>
and my
<?php //fetch_data.php include('database_connection.php'); if(isset($_POST["action"])) { $query = " SELECT * FROM voice_bank_data WHERE voice_status = '1' "; // if(isset($_POST["minimum_price"], $_POST["maximum_price"]) && !empty($_POST["minimum_price"]) && !empty($_POST["maximum_price"])) // { // $query .= " // AND product_price BETWEEN '".$_POST["minimum_price"]."' AND '".$_POST["maximum_price"]."' // "; // } // Gender if(isset($_POST["gender"])) { $gender_filter = implode("','", $_POST["gender"]); $query .= " AND voice_gender IN('".$gender_filter."') "; } // Genres if(isset($_POST["genres"])) { $genres_filter = implode("','", $_POST["genres"]); $query .= " AND voice_genres IN('".$genres_filter."') "; } // Voice Modulation if(isset($_POST["voice_modulation"])) { $voice_modulation_filter = implode("','", $_POST["voice_modulation"]); $query .= " AND voice_voice_modulation IN('".$voice_modulation_filter."') "; } // Languages if(isset($_POST["languages"])) { $languages_filter = implode("','", $_POST["languages"]); $query .= " AND voice_languages IN('".$languages_filter."') "; } // Jingle Moods if(isset($_POST["jingle_moods"])) { $jingle_moods_filter = implode("','", $_POST["jingle_moods"]); $query .= " AND voice_jingle_moods IN('".$jingle_moods_filter."') "; } // IVR if(isset($_POST["ivr"])) { $ivr_filter = implode("','", $_POST["ivr"]); $query .= " AND voice_ivr IN('".$ivr_filter."') "; } $statement = $connect->prepare($query); $statement->execute(); $result = $statement->fetchAll(); $total_row = $statement->rowCount(); $output = ''; if($total_row > 0) { foreach($result as $row) { $output .= ' <div class="col-sm-3 col-lg-4 col-md-3"> <div style="border:1px solid #ccc; border-radius:5px; padding:10px; margin-bottom:16px; height:300px;"> <audio controls controlsList="nodownload" style="padding: 10px 10px 10px 10px;margin-left: -21px;"> <source src="audio_sample/'. $row['voice_audio_file'] .'" alt="" class="img-responsive"> </audio> <p align="center"><strong> '. $row['voice_name'] .'</strong></p> <p style="font-size: 12px;"> Gender : '. $row['voice_gender'].' <br /> Genres : '. $row['voice_genres'].' <br /> Voice Modulation : '. $row['voice_voice_modulation'].' <br /> Languages : '. $row['voice_languages'].' <br /> Jingle Moods : '. $row['voice_jingle_moods'].' <br /> Ivr : '. $row['voice_ivr'].' <br /> </p> <button class="btn btn-primary" type="submit" style="padding: 5px 83px 5px 83px;"> Add to PlayList </button> </div> </div> '; } } else { $output = '<h3>No Data Found</h3>'; } echo $output; } ?>
How can i add add-to-cart functionality? https://snag.gy/xQ8TXP.jpg Edited June 10, 2019 by aveevaI have Win 7 home premium, Apache 2.2 (installed using the .msi) and PHP 5.2.14 (downloaded as "php-5.2.14-Win32-VC6-x86.zip", installed manually, it works) on both machines. The other is 32-bit and the other is 64-bit, both Windows 7 Home Premium. When I run the exactly same script on one machine, it does what it is supposed to (32-bit), but on the 64-bit it does not. Basically this appears in two situations (so far): I have a script that reads a (xml) file into a simplexml object, and if this is not successful, it prints an error message. On the 32-bit machine I can import (read) another xml file at once once the first one is processed (into a sqlite database), but on the 64-bit machine it gives me an error originating from the fact that the script did not manage to create the simplexml object. The other situation is when I want to open a specific PDF - file in a browser window (Firefox, the newest one, on the 32-bit machine, IE something newish on the 64-bit). The file exists, the path to the folder is in the Path environment variable, I can open it normally etc on the 64-bit machine, but when I click on a link that is supposed to open the file in a browser window I only get an error message saying that the file does not start with "%PDF.... Needless to say, the precisely same script works just fine on the 32 bit machine. $path_to_image="D:\\path_to_folder\\"; $file_name=$_GET['file_name']; header("Content-disposition: inline; filename=".$path_to_image.$file_name); header("Content-type: application/pdf"); readfile($path_to_image.$file_name); The above code is from the part that receives the file name from a form (other file). Anyone noticed anything like this? Any suggestions? Have been trying to figure this out for days, now... Oh, forgot: In both cases the thing is accessed as/from "localhost". Hi all. I'm using a cron job to pull the XML feed of my last five tweets, and using simplexml to parse and display the feed on my website. Here's the PHP I'm using--it works just fine, and displays exactly as I want it to: <?php $xml = simplexml_load_file('crontwitter.xml'); foreach ($xml->status as $status) { print "<p><span class=\"twittertext\">{$status->text}</span><br />"; print "<a class=\"twittertime\" href=\"http://twitter.com/#!/eaners/status/{$status->id}\" target=\"_blank\">"; echo date("j M Y, g:i A",strtotime($status->created_at)); print "</a></span></p>"; } ?> I'd like to add a touch more "intelligence" to this script, though. Namely, there are three things I'd also like to have this script do: I'd like to append "I" to any tweets that include the #fb hashtag, so that things display correctly (e.g., "I did such and such today" instead of just "did such and such today") I'd like to link to any other Twitter users mentioned (they would always be mentioned using the @username format) I'd like to link to a search for any other hash tag mentioned aside from #fb (they would always be included using the #tag format) I guess I'm not sure how exactly to further parse the XML file. I'll admit to being a relative newbie when it comes to PHP, so any assistance would be greatly appreciated! Hello all, My question is about a custom-coded latest-news plugin written by someone else. I don't know if it is generic, a copy of something else or what. It works good! but when I go to add a new news item to the list under Settings, it adds the item to the bottom of the list. The news is displayed on my homepage in short form and in full format on the primary news page. I need new items to be added to the TOP of the list instead or in reverse, so that in all the containers where it resides, the latest news item added is always at the top of the list. I know nothing about php but I am looking to learn. I plan on taking some basic classes on css and php to upgrade my archaic html skills, but I'm currently studying other subjects. Regardless, if this has a simple fix, I would be very interested in knowing what is needed and where/why. Here is the core of the php that I am finding in the plugin: There are three php files, This one says active, the other two say inactive so I get the impression they are not in use. Let me know if I should post their contents as well. Appreciate any help with this! My sincere thanks in advance. Labeled active: latest_news.php */ob_start();register_activation_hook(__file__, latest_news_install);function latest_news_install() { global $wpdb; $table_name = $wpdb->prefix . "latest_news"; if ($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) { $sql = "CREATE TABLE IF NOT EXISTS " . $table_name . " ( `id` int(10) NOT NULL AUTO_INCREMENT, `title` varchar(255) NOT NULL, `description` text NOT NULL, `date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (id) );"; mysql_query($sql) or die(mysql_error()); }}if( !function_exists('wp_latest_news_init') ) { function wp_latest_news_init() { add_shortcode( 'wp_latest_news', 'shortcode_latest_news'); }}if( !function_exists('shortcode_latest_news') ) { function shortcode_latest_news() { // extract(shortcode_atts(array('limit' => '5', ), $atts)); global $wpdb; $user_count = $wpdb->get_results("SELECT * FROM wp_latest_news ORDER BY date ASC LIMIT 4"); foreach ($user_count as $output) { $htmlOutput[] = "<li><b><a href='". get_permalink(287)."?news_id=".$output->id."'>" . $output->title . "</a></b></li>"; } //echo $htmlOutput; //echo "<pre>"; print_r($user_count); echo "</pre>"; foreach ($htmlOutput as $out) { echo $out; } return $htmlOutput; }}/* add_action('init', 'wp_latest_news_init' ) is used for call init function for create shortcode */add_action('init', 'wp_latest_news_init' );add_action('admin_menu', 'wp_latestnews_links' );function wp_latestnews_links() { add_submenu_page( 'options-general.php', __( 'Latest News ' ), __( 'Latest News ' ), 5 , 'latest_news_settings', 'latest_news_settings' );}// function latest_news_settings() {// global $wpdb;// if (isset($_POST["submit"])) {// $sql="INSERT INTO ".$wpdb->prefix . "latest_news(`title`,`description`) VALUES ('".$_POST['news_title']."','".$_POST['description']."') ";// //$sql=$wpdb->insert( $wpdb->latest_news, array( 'title' => $_POST['news_title'] ,'description' => $_POST['description'] ) );// mysql_query($sql) or die(mysql_error());// }// include 'Latest_news_setting.php';function latest_news_settings() { global $wpdb; $action = $_REQUEST["action"]; $id = $_REQUEST['id']; $sql = "SELECT * from ".$wpdb->prefix."latest_news "; $results = $wpdb->get_results($sql); //echo "<pre>";print_r($results); //$post_arr = query_posts(""); //echo "<pre>";print_r($post_arr);exit; switch ($action) { case 'add' : include('news_form.php'); break; case 'save' : if(isset($_POST['cancel'])) { include('latest_news_list.php'); } else if(isset($_POST['add'])) { $wpdb->query("insert into ".$wpdb->prefix."latest_news (`title`,`description`) VALUES ('".$_REQUEST['news_title']."','".$_REQUEST['description']."')"); //header("Location: http://localhost:81/Bravo/wp-admin/edit.php?page=slider_images"); header("location:?page=latest_news_settings"); } break; case 'edit' : $sql = "SELECT * from ".$wpdb->prefix."latest_news where id = '".$id."' "; $results_arr = $wpdb->get_results($sql); //echo "<pre>";print_r($results_arr); include('news_form.php'); break; case 'update' : if(isset($_POST['cancel'])) { include('news_form.php'); } else if(isset($_POST['edit'])) { //echo $id; $wpdb->query("update ".$wpdb->prefix."latest_news set title = '".$_REQUEST['news_title']."', description = '".$_REQUEST['description']."' where id='".$id."'"); header("location:?page=latest_news_settings"); } break; case 'delete' : $wpdb->query("delete from ".$wpdb->prefix."latest_news where id='".$id."'"); header("location:?page=latest_news_settings"); break; default: include('latest_news_list.php'); break; }}?>() I have these two classes: Code: [Select] <?php class A { private $id; public function __construct() { $this->id = '11111'; } public function getProperty($prop) { return $this->$prop; } }?> Code: [Select] <?php class B extends A { private $message = "Nope, can't see it"; public function __construct() { parent::__construct(); $this->message = "Yep, I can see it"; } }?> I tried this, but it just outputs the id (the first call) Code: [Select] $class = new B; echo $class->getProperty('id'); echo $class->getProperty('message'); Why is that? I thought I could use a parent method on a child property.. *EDIT* Using a public or protected visibility on the message property gets me the output I expect...how come? I am trying to make a login which works perfectly until I try and add remember me functionality into the User class. Hello Freaks, I am currently working on a status report web application. A user inputs what they are planning on accomplishing that week. Afterwords realizes that they made a mistake and need to correct it. The way I want to go about this is sql the database and return * where the username and report date are current. With the results of this query I insert them into the form as the value. This yields a populated form. From here I want the user to be able to change any line and submit the whole form. However, the post array is only populated with one row of data. I thought this might have to do with the names of the inputs all being the same so i tried to index those through the while loop with no luck. Any help would be appreciated! here's the code Code: [Select] <? // renaming sess var $UAID = $_SESSION['UAID']; $WEND = $_SESSION['WEEK_ENDING2']; //have we submitted our changes? if($EDIT == TRUE){ //how many task are there this week $results = mysql_query("Select COUNT(UAID) FROM `WPFTW` where UAID ='$UAID' and Rend = '$WEND'"); $row = mysql_fetch_row($results); //clean $_POST print_r($_POST); unset($_POST['Report']); echo "<br>"; print_r($_POST); } //what do we plan on editing $results = mysql_query("Select * FROM `WPFTW` where UAID ='$UAID' and Rend = '$WEND'"); //while there are results while($row = mysql_fetch_array($results)){ //increment for input name $k = 1; //date formatting list($year,$month,$day) = explode("-",$row['Target']); $row['Target'] = $month."-".$day."-".$year; //empty string to uncheck checkboxes $checked = ""; //populate checkboxes if($row['MS'] == "on"){ $checked = "yes"; } //select the correct drop down menu option if(isset($row['Status'])){ if($row['Status'] == " "){ $selected = "selected"; $selected1 = ""; $selected2 = ""; $selected3 = ""; } elseif($row['Status'] == "P"){ $selected = ""; $selected1 = "selected"; $selected2 = ""; $selected3 = ""; } elseif($row['Status'] == "C"){ $selected = ""; $selected1 = ""; $selected2 = "selected"; $selected3 = ""; } elseif($row['Status'] == "CL"){ $selected = ""; $selected1 = ""; $selected2 = ""; $selected3 = "selected"; } } //select the correct drop down menu option if(isset($row['OT'])){ if($row['OT'] == "Y"){ $selected4 = "selected"; $selected5 = ""; } elseif($row['OT'] == "N"){ $selected4 = ""; $selected5 = "selected"; } } //var to send form to self $cani = htmlentities($_SERVER['PHP_SELF']); //concatenate html & php for form $test = "<form id =\"2bigform\" action=$cani method = \"post\">" . "<tr>" . "<td><input id=\"hidden\" name=\"UAID$k\" type=\"hidden\" value=" . $_SESSION['UAID'] ."></td>". "<td width=\"7%\"> <input id=\"SR\#$k\" name=\"SR#\" type=\"text\" size=\"10%\" maxlength=\"10\" value=" . $row['SRNUM'] . "></td>" . "<td width=\"63%\"> <input id=\"Task$k\" name=\"Task\" type=\"textarea\" size=\"63%\" value=" . $row['Task'] . "></td>" . "<td width=\"7%\"> <select id=\"Status$k\" name=\"Status\">". " <option value=\" \" $selected></option>". " <option value=\"P\" $selected1>P</option>". " <option value=\"C\" $selected2>C</option>". " <option value=\"CL\" $selected3>CL</option>". "</select></td>". "<td width=\"7%\"> <input id=\"MS$k\" name=\"MS\" type=\"checkbox\" size=\"7%\" value=" . $row['MS'] . " checked = $checked></td>". "<td width=\"7%\"> <select id=\"OT$k\" name=\"OT\">". " <option value=\"Y\" $selected4>Y</option>". " <option value=\"N\" $selected5>N</option>". "</select></td>". "<td width=\"9%\"> <input id=\"Target$k\" name=\"Target\" type=\"text\" size=\"9%\" value=" . $row['Target'] . "></td>". "<input id=\"hidden\" name=\"RDate$k\" type=\"hidden\" value=" . $_SESSION['WEEK_ENDING'] ."></td></tr>"; echo $test; $k++; echo $k; } echo "</table>". "<input id=\"Sub\" type= \"Submit\" name=\"Report\" value= \"Submit\"/>". "</form>". "</body>". "</html>"; //<td width="7%"> <input id="SR#" name="SR#" type="text" size="10%" maxlength="10"/></td> //<td width="63%"> <input id="Task" name="Task" type="textarea" size= "63%"/></td> } ?> Hi There I am trying to create a page that edit mysql database from a php page. I can get the edit page to show the orginal information but it wont update the data in the mysql database. I am sure I have entered everything right. If anyone could help with this I would greatly appreciated <?php include("dbconnect.php"); if(isset($_POST['submit'])) { // Set global variables to easier names // and prevent sql injection and apostrophe to break the db. $ProductName = mysql_escape_string($_POST['ProductName']); $ProductText = mysql_escape_string($_POST['ProductText']); $ProductImage = mysql_escape_string($_POST['ProductImage']); $ProductPrice = mysql_escape_string($_POST['ProductPrice']); $result = mysql_query("UPDATE Product SET ProductName='$ProductName', ProductText='$ProductText', ProductImage='$ProductImage', ProductPrice='$ProductPrice' WHERE ID='$ID' ",$dbconnect); echo "<b>Thank you! Product UPDATED Successfully!<br>You'll be redirected to View Page after (2) Seconds"; echo "<meta http-equiv=Refresh content=2;url=view.php>"; echo "$ProductName <br> $ProductText <br> $ProductImage <br> $ProductPrice"; } elseif(isset($_GET['ID'])) { $result = mysql_query("SELECT * FROM Product WHERE ID='$_GET[ID]' ",$dbconnect); while($myrow = mysql_fetch_assoc($result)) { $ProductName = $myrow["ProductName"]; $ProductText= $myrow["ProductText"]; $ProductImage = $myrow["ProductImage"]; $ProductPrice = $myrow["ProductPrice"]; ?> <br> <h3>::Edit Product</h3> <form method="post" action="<?php echo $PHP_SELF ?>"> <input type="hidden" name="ID" value="<? echo $myrow['ID']?>"> Product Name: <input name="ProductName" size="40" maxlength="255" value="<? echo $ProductName; ?>"><br> Product Text: <textarea name="ProductText" rows="7" cols="30"><? echo $ProductText; ?></textarea><br> Product Image: <textarea name="ProductImage" rows="7" cols="30"><? echo $ProductImage; ?></textarea><br> Product Price: <textarea name="ProductPrice" rows="7" cols="30"><? echo $ProductPrice; ?></textarea><br> <input type="submit" name="submit" value="Update Product"> </form> <? }//end of while loop }//end else ?> Hi All, The Problem: I'm trying to learn how to take records from the NAME row of one table (i.e. Tom, Jim, Chris, Mike) and put them into a SELECT (drop down menu) box, then select a name and save it to a DIFFERENT table where the row is also called NAME, and THEN have that selection I just saved show in the SELECT box as SELECTED when the page refreshes. I have found a hundred websites showing how to bind a SELECT box to a table and put them into a SELECT box via $key => $val and even how to save it to ANOTHER textbox on the page, which is a lot easier, but never a step further as described in the first paragraph above. Seems unbelievable to me since it's so common. Maybe I'm just not using the proper search terms/keywords. Here's an example: Let's say you wanted to notify 3 people of your birthday. So, on the notification page, you would enter three names of people you would want notified all in separate input textboxes with [keys]. So, you enter John, Chris, and Tom into three text boxes and save the page. Done. Now, on another page, I have -- say .... five select boxes. For arguments sake, let's just say I click on all of them one at a time. In each of them, I would only see three names (John, Chris, and Tom). Now, in the first SELECT box I click on John. In the second select box I click on Chris, and on the third I click on Tom. Then save the form. I would like to see John, Chris, and Tom in the first three boxes after refreshing and I would like to see SELECT A NAME on the last two Select boxes that we never did anything with. Remember, there are NO default names in the first table with row called NAMES. They are populated by the user and saved to the row. I'm attaching an image of what the page looks like that I want to see the names and be able to select them. Does anyone have a link to a site that shows how to do this... or maybe have something very basic that would show me the process? Or, if not too difficult, maybe you could show me? Thanks in advance for any help! Attached Files Untitled.jpg 24.97KB 0 downloads hi, i have made a website where people resgister their details of them and products. they have to enter the following details in form Name of company name of the product company address email id password mobile number contact and brief details about their company
user can then login with email id and pwd. now after login ..user will get a page where he can upload the photos of products images and their price, so now my question is that when he finishes uploading (|by clicking on upload button) the product images and price text box ..then on final uploaded webspage it should show all other things which he registerd before (company name , mobile number etc) along with images and price...hence the main question that user does not need to enter mobile and address while uploading images and filling proce ..but on the final page it should show mobile and address along with price and images..as user is not going to enter mobile and address again and again as he will have multiple products to upload.
I would appreciate your assistance, there are tons of login scripts and they work just fine. However I need my operators to login and then list their activities for the other operators who are logged in to see and if desired send their clients on the desired activity. I have the login working like a charm and the activities are listed just beautifully. How do I combine the two tables in the MySQL with PHP so the operator Logged in can only make changes to his listing but see the others. FIRST THE ONE script the member logges in here to the one table in MSQL: <?php session_start(); require_once('config.php'); $errmsg_arr = array(); $errflag = false; $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } function clean($str) { $str = @trim($str); if(get_magic_quotes_gpc()) { $str = stripslashes($str); } return mysql_real_escape_string($str); } $login = clean($_POST['login']); $password = clean($_POST['password']); if($login == '') { $errmsg_arr[] = 'Login ID missing'; $errflag = true; } if($password == '') { $errmsg_arr[] = 'Password missing'; $errflag = true; } if($errflag) { $_SESSION['ERRMSG_ARR'] = $errmsg_arr; session_write_close(); header("location: login-form.php"); exit(); } $qry="SELECT * FROM members WHERE login='$login' AND passwd='".md5($_POST['password'])."'"; $result=mysql_query($qry); if($result) { if(mysql_num_rows($result) == 1) { session_regenerate_id(); $member = mysql_fetch_assoc($result); $_SESSION['SESS_MEMBER_ID'] = $member['member_id']; $_SESSION['SESS_FIRST_NAME'] = $member['firstname']; $_SESSION['SESS_LAST_NAME'] = $member['lastname']; session_write_close(); header("location: member-index.php"); exit(); }else { header("location: login-failed.php"); exit(); } }else { die("Query failed"); } ?> ................................................. ................................ Now I need the person who logged in to the table above to be able to make multiple entries to the table below <? $ID=$_POST['ID']; $title=$_POST['title']; $cost=$_POST['cost']; $activity=$_POST['activity']; $ayear=$_POST['aday']; $aday=$_POST['ayear']; $seats=$_POST['special']; $special=$_POST['seats']; mysql_connect("xxxxxx", "xxx350234427", "========") or die(mysql_error()); mysql_select_db("xxxx") or die(mysql_error()); mysql_query("INSERT INTO `activity` VALUES ('ID','$title', '$cost','$activity', '$aday', '$ayear', '$special', '$seats')"); Print "Your information has been successfully added to the database!" ?> Click <a href="member-profile.php">HERE</a> to return to the main menu <?php ?> Actually, what i want to do is to use the email to fetch the $email,$password and $randomnumber from database after |