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. This code works without problems: <?php namespace NamespaceA; class A extends \NamespaceB\B {} namespace NamespaceB; class B {} But why the following code cause Fatal error: Class 'NamespaceB\B' not found in ...file? <?php namespace NamespaceA; class A extends \NamespaceB\B {} namespace NamespaceB; class B extends \NamespaceC\C {} namespace NamespaceC; class C {} And this code also works without problems: <?php namespace NamespaceA; class A extends \NamespaceB\B {} namespace NamespaceC; class C {} namespace NamespaceB; class B extends \NamespaceC\C {} Without any namespace, also Fatal error: Class 'B' not found in ...file: <?php class A extends B {} class B extends C {} class C {} Works without problems: <?php class A extends B {} class B {} And yes everything is in the same PHP file....
  2. so my situation is something like this , i'm trying to fetch user details based on `id` that isset is getting, but some how the `variable that contains the $_GET value doesn't work` in query but when i put an static value to pdo query then it works and show the result. i have checked by doing `var_dump` of variable `$user` before query and it shows the correct value but not working in query. Below is the code i'm working with: public function profile_view($user_id = null) { $user = $user_id; $stmt = $this->_db->prepare('SELECT memberID,username,email,profile_pic,active FROM members WHERE memberID = :user_id AND active="YES"'); $stmt->execute(array(':user_id'=>$user)); while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $user_det = (object) array('username'=> $row['username'],'email'=>$row['email'],'profile_pic'=>$row['profile_pic'],'id'=> $row['memberID'],'active'=>$row['active']); return $user_det; } } this is how function is being called (profile_view function is child of User class so $user is class User) : $view_profile = $user->profile_view($_GET['u']); the above code returns null but when i put static value : `5` at the place of `$user` in `$stmt->execute` it returns the whole user's details which is what i need , but its not working with variable which is confusing me alot , thanks in advanced for help.
  3. Hello all, I am new in php and would like to help me in in code. I would like to implement a html form that will upload to my linux server some files, some info as well and will run a bash command. To be more clear, users will: Send to the linux server two files (I have done it). Select from a drop down list a specific directory, and once this specific directory has been selected to activate one other drop down menu with its childs. Send all those info to a bash script. For case b, assume that we have the following structure my_dir/cars/brand1 my_dir/cars/brand2 my_dir/cars/brand3 my_dir/motors/brand5 my_dir/motors/brand6 the first drop down list should list only cars and motors while the second only brand1, brand2, and brand3 if cars is selected or brand5 and brand6 if motors is selected. For case c, once the form is submitted, I would like the command: ./script.sh –a uploadedfile1 –b uploadedfile2 –c dropdown1 –d dropdpwn2 Any help is appreciated. Best,
  4. I have created 5 websites under 5 different domains. Contents of this websites' are similar and using a same template for each one. Now I need to create an admin panel to control these websites. PHP and MySql I will use for this backend. My problem is how can I manage these five website with one backend? Reason is I will use different domain for my backend. My all 5 client will use this same backend system to manage their own website. So can I know from the professionals here, is it possible to display mysql data on these 5 website. If it is possible then how? Any links to article or tutorials would be welcome and appreciated. NOTE: I checked mysql federated storage engine but no idea? Is it the way where do I need to go? Thank you.
  5. Evening everyone and Merry X-Mas (Happy Holidays) or whatever fits you best.... I have been trying over and over for about 12 hours to figure out how to get data from a specific JSON response and assign the specific values to a new array key/value pair. The various ways I have tried to figure this out are numerous so i'm going to avoid the runnig list of "I trieid this...and this...and this... etc etc." just understand I have reached a dead end point where I need help badly. Here is what our end goal is: "The company" is a "service industry" provider (plumbing, electrical etc. etc.) who wants to dispatch its technicians to new jobs based on which technician has the shortest travel time from any existing address where they already have a scheduled appointment that day and has available time in there schedule. Thus the dispatching system when a new service call is entered is going to give "recommended" technicians (up to 4) to be assigned the new service call based on the above mentioned criteria. (Efficient routing to save company gas cost) 1.) We have a "New service" street address assigned to the $to variable: $to = "4813 River Basin Dr S, Jacksonville FL 32207"; 2.) We will have "records" array which containes a series of records, each record consists of a ticket# a technician id# and a street address: $records = array( array("DV1012","30453423","9890 Hutchinson Park Dr Jacksonville, FL 32225"), array("DB3434","30404041","821 Orange Ave Crescent City, FL 32112"), array("DB3434","30605060","1972 Wells Road, Orange Park FL 32073"), array("DB4578","30605060","2 Independent Drive, Jacksonville FL 32202"), array("DB7841","30605060","5000 Norwood Avenue, Jacksonville FL 32208"), array("DB3235","30605060","9501 Arlington Expressway, Jacksonville FL 32225"), array("DB7894","30605060","Massey Avenue, Jacksonville, FL 32227"), array("DB2020","30121212","11200 Central Pkwy Jacksonville, FL 32224") ); 3.) We are going to prepare the records array for submission to Google's Distance Matrix API by URL encoding each array value into a single variable and then submit it: foreach ($records as $key => $value) {$from = $from.urlencode($value[2])."|";} $to = urlencode($to); $data = file_get_contents("//maps.googleapis.com/maps/api/distancematrix/json?origins=$from&destinations=$to&language=en-EN&units=imperial&mode=driving&sensor=false"); $res=json_decode($data) or die("Error: Cannot read object"); You may look at the ACTUAL live Google response from this here: http://tiny.cc/i6eerx (We have applied <pre> and var_dump($res) to the output) We are looking to get the following information back: The distance and travel time between the "New Service" address ($to) and each of the address' in the $records array ($from), now once that information is returned from Google (JSON response) we need to parse the response and narrow it down to 4 or less (Based on the 4 lowest drive times) to form a new array which ends like this: $results = array( array("DV1012","30453423","2.3 Miles","8 mins"), array("DB3434","30404041","2.8 Miles","9 mins"), array("DB3434","30605060","4.6 Miles","13.8 mins"), array("DB4578","30605060","5.7 Miles","15.2 min") ); OUR PROBLEM: Everything up until the the Google API response is fine, but iterating over the multidimensional arrays within multidimensional arrays of the JSON response is just not coming together in my head (or 2 dozen code attempts). I am able to ECHO an individual value like ( echo $res->rows[0]->elements[0]->distance->text; ) but this has no value for the end result i need to get to. My last thoughts and efforts was that that I was going to have to embed foreach statements within foreach statements to drill down through the various arrays but that hasn't worked very well and it seems like it shouldn't be how it has to be done. I would appreciate any help in showing me how the iteration code should be written and any explanation about the code so i can wrap my head around it.
  6. i have a code in c# and here use GetBytes(msg) for SSlStream.write, here send and received data correctly, here all work fine, now i want to make the same event in php, but here i cant see a SslSteam or similar(i think no problem, becouse i working with socket_connection, and i think SSL is only for security), now for compare i stop the code in c# for see what data is sending and try to convert in php, for send here, i can see a data byte{} in c# and with ` $message=unpack('C*',$message);` i can convert the string to byte[], comparing with c# value is the same so, here all is ok, my problem is when i try to write the request, becouse in SslStream.write accpet byte[] but socket_write no accept whe i try send ` socket_write($socket, '\n', strlen($message))` i have a error : socket_write() expects parameter 2 to be string and obvius is becouse socket_write() only accept string, but so.. as i can send my byte[], becouse the server only accept a byte[] please help me PD> my problem is how i can send the byte[], i dont know if can send eq socket_write($socket, $message[1], strlen($message)), or what is which is the right way, note please $message first is a string as the server only accept byte i use unpack for create a $message[] as byte/integer eq with 70 items, etc, here is ok, becouse comparing with my program in c# give the same value(same array), but now i need send this $message[], but i cant becouse $message now is a byte or integer[], and socket_write only aceppt string, please help me
  7. Hi all. In my database, i have a column recurring which is derived from a multiple option form field with values: Weekly, Bi-Monthly, Monthly, Quarterly, Half Yearly and Yearly. I want to have as next due the current date plus the recurring value. eg current date = 2014-11-24 recurring = monthly next due = current date + recurring (in the next due will be 2014-12-24) so i did: $stmt = $pdo->query("SELECT recurring, due_date FROM $table"); while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $recur = $row['recurring']; $date_due = $row['due_date']; } $weekly = "Weekly"; $bi_monthly = "Bi-Monthly"; $monthly = "Monthly"; $quarterly = "Quarterly"; $half_yearly = "Half Yearly"; $yearly = "Yearly"; if(strcmp($recur, $weekly) == 0){ $recurs = "7 DAY"; }elseif(strcmp($recur, $bi_monthly) == 0){ $recurs = "14 DAY"; }elseif(strcmp($recur, $monthly) == 0){ $recurs = "1 MONTH"; }elseif(strcmp($recur, $quarterly) == 0){ $recurs = "3 MONTH"; }elseif(strcmp($recur, $half_yearly) == 0){ $recurs = "6 MONTH"; }elseif(strcmp($recur, $yearly) == 0){ $recurs = "1 YEAR"; } $stmt = $pdo->query("SELECT ADDDATE('$date_due', INTERVAL $recurs) as nex_due FROM $table"); $row = $stmt->fetch(PDO::FETCH_ASSOC); $nex_due = $row['nex_due']; $stmt = $pdo->prepare("SELECT * FROM $table ORDER BY trans_id DESC"); $stmt->execute(); $num_rows = $stmt->rowCount(); while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { // Print out the contents of each row into a table echo "<tr><td>"; echo $row['trans_ref']; echo "</td><td>"; echo $row['acct_num']; echo "</td><td>"; echo ucwords($row['payee']); echo "</td><td>"; echo ucwords($row['company']); echo "</td><td>"; echo $row['acct_no']; echo "</td><td>"; echo number_format($row['amt'],2); echo "</td><td>"; echo $row['purpose']; echo "</td><td>"; echo $row['recurring']; echo "</td><td>"; echo $row['due_date']; echo "</td><td>"; echo $nex_due; echo "</td><td>"; echo "<strong>".$row['status']."</strong>"; echo "</td><td>"; echo "<strong>".$row['pay_status']."</strong>"; echo "</td><td>"; } The problem is that it's giving me as next due the value of the first row even when the recurring is different!
  8. Hey guys so my code below is not working, it will get the app information for the user but its only display 3 results like every time a new user "installs" an new app like it stops showing the last result and starts displaying the new result. Like for example right now it should be showing 7 results but only displaying 3 is there something wrong with my query. (PS: this is just developement testing purposes so thats why my code is sorta sloppy) Thanks! $default_apps = mysql_query("SELECT * FROM apps WHERE `default`='1'") or die(mysql_error()); $user_apps = mysql_query("SELECT * FROM user_apps WHERE `user_id`='$user_id'") or die(mysql_error()); while($row = mysql_fetch_array($default_apps)) { $url = $row['download_url']; $name = $row['name']; echo $row['name']; echo "<a href='$url'>$name</a><br />"; } while($raw = mysql_fetch_array($user_apps)){ $app_id = $raw['app_id']; } $select_user_apps = mysql_query("SELECT * FROM apps WHERE `app_id`='$app_id' "); while($rop = mysql_fetch_array($select_user_apps)) { $name = $rop['name']; $url = $rop['download_url']; echo $name; echo $url; }
  9. Hey guys so I am making an App website and somehow need to make a developer section. So like developers can come and setup their app name,description etc. Then be able to program there own app and use like an API service to get the user username etc. So what would I need to let developers do a such thing like let them make an API key and all that is there some tutorial to make such service. (This will be an important feature to my website so please help, thanks)
  10. Hey guys so I am making an online App website. So I need to it to be so some apps will be added by default. Then users can search for apps and "install" apps but really just have them show up on the homepage. So how would the database design work like have a field that is updated to 1 if the user has it installed and 0 if its not. And then do like an if statement to pull all the fields with 1 where username='$username'. And when it pulls it should I add like a URL field to it to so when it pulls the app information there will be a link to the app url. Could somebody please help me with what I should do because I am really confused on what design and if statements I should use
  11. Hello everyone. I have a fully working form that gets data from a user (with $_post array) , and stores it in a database (mysql). After successfulIy filling the form, I refer him to the "dashboard" page. In this page, i am having trouble to get his details from the database. How should I recognize him as the user that just registered? should I use a $_post? or maybe a session? could you please give me a clue how to solve this?
  12. For eg. I have a page with a query that retrives records from the database and I want to have options of filtering out the shown records by date, time, likes, views..etc; how would I go about doing that? The way I am thinking is having a html form with those filter inputs and using a relative query based on the filter selection to retrive the results. What you think?
  13. I have these two tables... schedule (gameid, homeid, awayid, weekno, seasonno) teams (teamid, location, nickname) This mysql query below gets me schedule info for ALL 32 teams in an array... $sql = "SELECT h.nickname AS home, a.nickname AS away, h.teamid AS homeid, a.teamid AS awayid, s.weekno FROM schedule s INNER JOIN teams h ON s.homeid = h.teamid LEFT JOIN teams a ON s.awayid = a.teamid WHERE s.seasonno =2014"; $schedule= mysqli_query($connection, $sql); if (!$schedule) { die("Database query failed: " . mysqli_error($connection)); } else { // Placeholder for data $data = array(); while($row = mysqli_fetch_assoc($schedule)) { if ($row['away'] == "") {$row['away']="BYE";} $data[$row['homeid']][$row['weekno']] = $row['away']; $data[$row['awayid']][$row['weekno']] = '@ '.$row['home']; } } However, I only want to get info for one specific team, which is stored in the $teamid variable. This should be very easy, right? I have tried multiple things, including this one below (where I added an AND statement of "AND (h.teamid=$teamid OR a.teamid=$teamid)"), but this one still outputs too much... $sql = "SELECT h.nickname AS home, a.nickname AS away, h.teamid AS homeid, a.teamid AS awayid, s.weekno FROM schedule s INNER JOIN teams h ON s.homeid = h.teamid LEFT JOIN teams a ON s.awayid = a.teamid WHERE s.seasonno =2014 AND (h.teamid=$teamid OR a.teamid=$teamid)"; $schedule= mysqli_query($connection, $sql); if (!$schedule) { die("Database query failed: " . mysqli_error($connection)); } else { // Placeholder for data $data = array(); while($row = mysqli_fetch_assoc($schedule)) { if ($row['away'] == "") {$row['away']="BYE";} $data[$row['homeid']][$row['weekno']] = $row['away']; $data[$row['awayid']][$row['weekno']] = '@ '.$row['home']; } } Below is the array that the above outputs. In a nutshell, all I want is that 1st array ([1]) which has, in this example, the Eagles full schedule. It's not giving me too much else and I guess I could live with it and just ignore the other stuff, but I'd rather be as efficient as possible and only get what I need... Array ( [1] => Array ( [1] => Jaguars [2] => @ Colts [3] => Redskins [4] => @ 49ers [5] => Rams [6] => Giants [7] => BYE [8] => @ Cardinals [9] => @ Texans [10] => Panthers [11] => @ Packers [12] => Titans [13] => @ Cowboys [14] => Seahawks [15] => Cowboys [16] => @ Redskins [17] => @ Giants ) [27] => Array ( [1] => @ Eagles ) [28] => Array ( [2] => Eagles ) [4] => Array ( [3] => @ Eagles [16] => Eagles ) [14] => Array ( [4] => Eagles ) [15] => Array ( [5] => @ Eagles ) [3] => Array ( [6] => @ Eagles [17] => Eagles ) [] => Array ( [7] => @ Eagles ) [16] => Array ( [8] => Eagles ) [25] => Array ( [9] => Eagles ) [11] => Array ( [10] => @ Eagles ) [7] => Array ( [11] => Eagles ) [26] => Array ( [12] => @ Eagles ) [2] => Array ( [13] => Eagles [15] => @ Eagles ) [13] => Array ( [14] => @ Eagles ) )
  14. Say I have a table called artists with these fields (artistid, rank). Then say I have an array called $rankadjustments with a value for each artist (like 1, 7, 3,-3, 5, 9, etc). I am doing a MYSQL query that gets the info from artists table and sorts according to the rank field like this... $sql = "SELECT * FROM artists ORDER BY rank"; Easy enough. But what if I would like to bring that data back sorted by (rank + rankadjustment). For example, if the artist ranked 1st had a rank of "1" from mysql, but had a rankadjustment of "5" from the rankadjustment array, his "true" rank would be "6". Again, rankadjustment is NOT a field in my table, otherwise it would obviously be simple. It's calculated on the fly and stored in an array. FYI, the array has an index with their "artistid". For example, $rankadjustment[341][8] would be the artist with an artistid of "341" has a rank adjustment of 8. Is there a way to do this IN the query itself? It doesn't seem possible but wanted to find out for sure. If not, what is best way to do? I assume... Get the data sorted JUST by rank and put it all into an array, then create a new array that adds rank to rankadjustment and reorder by the "new" rank amount? I guess that wouldn't be too bad but again, wanted to make sure I'm not missing something that would allow me to do it all in the query (or just more efficiently). Thanks!
  15. I am using xampp. <a href="/">Home Page</a> The above code (when clicked in browser) takes me to the localhost instead of localhost/website How can i clear this issue?
  16. hello dear folks good evening dear PHP-Freaks, well i am not sure if this question fits here - in miscellaneous. but i am pretty sure that many many calc and excel-experts are here in this great forum. what is aimed: want to create a calendar - with 365-chunks that are imported into a caleandar form see some ideas where i can import this i posted the example-calc spreassheet that i want to import. note it has got 365 lines - for 365 days of the next year 2015 what needs to be done ; whats needs to be achieved: i need to impoort the example into the calendar form. see some of the examples -.. if i am able to import the texts (of the collumn ) in a writer or word document each line of the calc needs to get on a sheed of the word or writer. i need to know how to arrange this export of calc into the writer document. if i need to explain it more thoroughiy - just let me know! greetings you matze see some examples of calendar templates Blank daily calendar - Templates Daily lesson planner (color, landscape) - Templates note: all i need to know is to be able to export from calc to any word or calc document... see the attached sample below... 2015_sample_version_.ods.zip
  17. I'm a beginner here and i am learning the basic in converting from MySQL to MySQLi. I am currently working on this registration page which I would want to convert to MySQLi. Please advise me how to modify this script, I would prefer the procedural style. The MySQLi coding is not working because it would notg insert into the database like the MySQL coding would, would appreciate if your can help me. MYSQL <?php error_reporting(1); $submit = $_POST['submit']; //form data $name = mysql_real_escape_string($_POST['name']); $name2 = mysql_real_escape_string($_POST['name2']); $email = mysql_real_escape_string($_POST['email']); $password = mysql_real_escape_string($_POST['password']); $password2 = mysql_real_escape_string($_POST['password2']); $email2 = mysql_real_escape_string($_POST['email2']); $address = mysql_real_escape_string($_POST['address']); $address2 = mysql_real_escape_string($_POST['address2']); $address3 = mysql_real_escape_string($_POST['address3']); $address4 = mysql_real_escape_string($_POST['address4']); $error = array(); if ($submit) { //open database $connect = mysql_connect("localhost", "root", "Passw0rd") or die("Connection Error"); //select database mysql_select_db("logindb") or die("Selection Error"); //namecheck $namecheck = mysql_query("SELECT * FROM users WHERE email='{$email}'"); $count = mysql_num_rows($namecheck); if($count==0) { } else { if($count==1) { $error[] = "<p><b>User ID taken. Try another?</b></p>"; } } //check for existance if($name&&$name2&&$email&&$password&&$password2&&$email2&&$address&&$address2&&$address3&&$address4) { if(strlen($password)< { $error[] = "<p><b>Password must be least 8 characters</b></p>"; } if(!preg_match("#[A-Z]+#",$password)) { $error[] = "<p><b>Password must have at least 1 upper case characters</b></p>"; } if(!preg_match("#[0-9]+#",$password)) { $error[] = "<p><b>Password must have at least 1 number</b></p>"; } if(!preg_match("#[\W]+#",$password)) { $error[] = "<p><b>Password must have at least 1 symbol</b></p>"; } //encrypt password $password = sha1($password); $password2 = sha1($password2); if($_POST['password'] != $_POST['password2']) { $error[] = "<p><b>Password does not match</b></p>"; } //rescue email match check if($_POST['email2'] == $_POST['email']) { $error[] = "<p><b>Rescue Email must not be the same as User ID</b></p>"; } //generate random code $random = rand(11111111,99999999); //check for error messages if(isset($error)&&!empty($error)) { implode($error); } else { //Registering to database $queryreg = mysql_query("INSERT INTO users VALUES ('','$name','$name2','$email','$password','$password2','$email2','$address','$address2','$address3','$address4','$random','0')"); $lastid = mysql_insert_id(); echo "<meta http-equiv='refresh' content='0; url=Activate.php?id=$lastid&code=$random'>"; die (); } } } ?> MYSQLi (NOT WORKING AFTER CONVERTING) <?php error_reporting(1); $submit = $_POST['submit']; //form data $name = mysqli_real_escape_string($connect, $_POST['name']); $name2 = mysqli_real_escape_string($connect, $_POST['name2']); $email = mysqli_real_escape_string($connect, $_POST['email']); $password = mysqli_real_escape_string($connect, $_POST['password']); $password2 = mysqli_real_escape_string($connect, $_POST['password2']); $email2 = mysqli_real_escape_string($connect, $_POST['email2']); $address = mysqli_real_escape_string($connect, $_POST['address']); $address2 = mysqli_real_escape_string($connect, $_POST['address2']); $address3 = mysqli_real_escape_string($connect, $_POST['address3']); $address4 = mysqli_real_escape_string($connect, $_POST['address4']); $error = array(); if ($submit) { //open database $connect = mysqli_connect("localhost", "root", "Passw0rd", "logindb") or die("Connection Error"); //namecheck $namecheck = mysqli_query($connect, "SELECT * FROM users WHERE email='{$email}'"); $count = mysqli_num_rows($namecheck); if($count==0) { } else { if($count==1) { $error[] = "<p><b>User ID taken. Try another?</b></p>"; } } //check for existance if($name&&$name2&&$email&&$password&&$password2&&$email2&&$address&&$address2&&$address3&&$address4) { if(strlen($password)< { $error[] = "<p><b>Password must be least 8 characters</b></p>"; } if(!preg_match("#[A-Z]+#",$password)) { $error[] = "<p><b>Password must have at least 1 upper case characters</b></p>"; } if(!preg_match("#[0-9]+#",$password)) { $error[] = "<p><b>Password must have at least 1 number</b></p>"; } if(!preg_match("#[\W]+#",$password)) { $error[] = "<p><b>Password must have at least 1 symbol</b></p>"; } //encrypt password $password = sha1($password); $password2 = sha1($password2); if($_POST['password'] != $_POST['password2']) { $error[] = "<p><b>Password does not match</b></p>"; } //rescue email match check if($_POST['email2'] == $_POST['email']) { $error[] = "<p><b>Rescue Email must not be the same as User ID</b></p>"; } //generate random code $random = rand(11111111,99999999); //check for error messages if(isset($error)&&!empty($error)) { implode($error); } else { //Registering to database $queryreg = mysqli_query($connect, "INSERT INTO users VALUES ('','$name','$name2','$email','$password','$password2','$email2','$address','$address2','$address3','$address4','$random','0')"); $lastid = mysqli_insert_id(); echo "<meta http-equiv='refresh' content='0; url=Activate.php?id=$lastid&code=$random'>"; die (); } } } ?>
  18. Hello every1, I'm trying to create a magazine wesite and I dont want anybody to access my images folder which is located in the root directory. I want some thing like this... I want to call the images in my website using <img> tag but I dont want any1 to access the directory directly. It should also protect from software bots also like (HTTrack or website Copier) It should show "Access forbidden". Any help will be greatly appreciated. Thank you...
  19. Below is my code that is suppose to insert and show records from database using ajax. Retrieving the records from the database works. However it won't insert a record. I do not get any errors. The page simply refreshes when I hit submit button. Can you see what might be wrong in my code? index.php <script> $(document).ready(function(){ function showComment(){ $.ajax({ type:"post", url:"process.php", data:"action=showcomment", success:function(data){ $(".wrapper").html(data); } }); } showComment(); $("#submit").click(function(){ var name=$("#name").val(); var message=$("#details").val(); $.ajax({ type:"post", url:"process.php", data:"name="+name+"&details="+message+"&action=addcomment", success:function(data){ showComment(); } }); }); }); </script> $id = $_GET['id']; $title = $_GET['title']; $_SESSION['id'] = $id; $_SESSION['title'] = $title; <div class="wrapper"></div> <form action="" method="post" enctype="multipart/form-data"> <div class="newfield"> <label for="title">Name <span class="highlight">*</span></label> <input id="name" type="text" name="name"> </div> <div class="newfield"> <label for="details">Details <span class="highlight">*</span></label> <textarea id="details" name="details""></textarea> </div> <input type="submit" name="submit" id="submit" value="Submit Tale"> </form> process.php <?php require_once '/core/init.php'; $id = $_SESSION['id']; $action = $_POST['action']; if($action == 'showcomment') { try { $get = $db->prepare("SELECT * FROM sub_posts WHERE id = :id"); $get->bindParam('id', $id); $get->execute(); $getStmt = $get->fetchAll(PDO::FETCH_ASSOC); if(count($getStmt) > 0) { foreach($getStmt as $row) { $new_name = $row['name']; $new_details = $row['details']; ?> <ul> <li> <?php echo $new_name; ?> </li> <li> <?php echo $new_details; ?> </li> </ul> <?php } } else { // no records found. } } catch(Exception $e) { die($e->getMessage()); } } else if($action == 'addcomment') { $name = $_GET['name']; $details = $_GET['details']; try { $insert = $db->prepare("INSERT INTO sub_posts(id, name, details) VALUES(:id, :name, :details)"); $insert->bindParam('id', $id); $insert->bindParam('name', $name); $insert->bindParam('details', $details); $insert->execute(); if($insert == false){ echo 'record could not be inserted.'; } else { echo 'record has been inserted.'; } } catch(Exception $e) { die($e->getMessage()); } } else { echo 'no results.'; }
  20. hello dear linux-community if a server needs to meed some requirements - eg for installation wordpress and if the server needs to run eg see here: https://wordpress.org/about/requirements/ then i need to have a closer look at the apache2handler in the php-ini Apache Version Apache all the mentioned are listed in the php-info.file note: here are no mod_rewrite Apache module so what
  21. I have this code I have been trying ot use but it doesnt sent an email to my account when someone enters there email address into it and hots the submit button this is the php side of it <?php if ( isset( $_POST['newsletter_submit'] ) ) { // Initialize error array $newsletter_errors = array(); // Check email input field if ( trim( $_POST['newsletter_email'] ) === '' ) $newsletter_errors[] = 'Email address is required'; elseif ( !preg_match( "/^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,4}$/i", trim( $_POST['newsletter_email'] ) ) ) $newsletter_errors[] = 'Email address is not valid'; else $newsletter_email = trim( $_POST['newsletter_email'] ); // Send email if no input errors if ( empty( $newsletter_errors ) ) { $email_to = "news@upperhuntercomputers.com"; // Change to your own email address $subject = "Newsletter Subscription"; $body = "Subscriber details: " . $newsletter_email . "\r\n"; $headers = "Newsletter Subscription <" . $email_to . ">\r\nReply-To: " . $newsletter_email . "\r\n"; mail( $email_to, $subject, $body, $headers ); echo 'Thank you for subscribing!'; } else { echo 'Please go back and correct the following errors:<br />'; foreach ( $newsletter_errors as $error ) { echo $error . '<br />'; } } } ?> and this is the html side of it <!-- Newsletter form --> <div class="newsletter"> <form action="subscribe.php" method="post" id="newsletter-form"> <p class="form-field"> <label for="newsletter_email" class="visually-hidden">Your email address</label> <i class="icon ion-paper-airplane" aria-hidden="true"></i> <input type="text" name="newsletter_email" id="newsletter_email" value="" placeholder="Your email address" /> </p> <p class="form-submit"> <input type="submit" name="newsletter_submit" id="newsletter_submit" value="Get Notified" /> </p> </form> </div> </div> cant figure out why its not working properly
  22. <?php if(isset($_POST['submit'])){ //collect form data $location = $_POST['location']; $ID = $_POST['ID']; $section = $_POST['section']; //check name is set if($location ==''){ $error[] = 'Name is required'; } //if no errors carry on if(!isset($error)){ # Title of the CSV $Content = "location, ID, section\n"; //set the data of the CSV $Content .= "$location, $ID, $section\n"; # set the file name and create CSV file $my_file = ("$location$ID$section.cvs"); $handle = fopen("$my_file", "w") or die('Cannot open file: '.$my_file); header('Content-Type: application/csv'); header('Content-Disposition: attachment; filename="' . $FileName . '"'); echo $Content; exit(); } } //if their are errors display them if(isset($error)){ foreach($error as $error){ echo "<p style='color:#ff0000'>$error</p>"; } } ?> <form action='' method='post'> <p><label>Location:</label><br><input type='text' name='location' value=''></p> <p><label>ID:</label><br><input type='text' name='ID' value=''></p> <p><label>Section:</label><br><input type='text' name='section' value=''></p> <p><input type='submit' name='submit' value='Submit'></p> </form> I have wrote a .php file which is a form with 3 different fields, in these fields I want to write entries which lateron will be submitted into a .csv generating a csv file on my server with the name of the entries. The issue is that the file is not being generated on my server. With the current code the entries are being recognized and being placed in the filename of the csv. The point is not to make it downloadable sinds I want to have it on my webserver and keep editing information in it. My code is top of this post. My .php file replies that: Cannot open file: BOD10Buffer.csv Pardon my sloppy code everyone, I am not really a person that codes but this "form" may save me a lot of time in the longrun, just difficult and I am asking for help on this. Is there anyone that may be kind enough to help me? and as to what I might be doing wrong? All help is much appreciated!
  23. hi everyone i keep seeing the following Comparison Operators: <> i see it used in the following context: if ($connection <> 'SSL') { $connection = 'NONSSL'; } be grateful if somone would tell me what it means, i looked online but could not find the symbol thanks
  24. Hello Guys. I am having a trouble viewing a specific column content both in phpMyAdmin and console.It only shows a partial info about the contents inside that column. I have attached a screenshot of this to give you a demonstration inside that link: http://i59.tinypic.com/2n6ymqf.jpg as you can see , the user picked hamburger ,steak and ground beef (and some more), but it seems that it stops showing it right in the middle of the word. Is there any limit for characters in this case? What would be possible to figure that out please? Thanks in advance..
  25. I'm having two issues: (1) The correct mysql query for multiple rows (2) The if/elseif/else to pull data from these rows, and process it based on the row data I'm only pulling data where A=1 and B=1,2 -- so two possible entries there (call them B1 and B2). I need a php if statement to choose whether the output of B is one of two urls (b1=google,b2=bing). The actual script is far more complex, with more than just 1,2 from B. I've stripped all the excesses down to this one if/else issue and the db query. The output php doesn't matter here. And I can add more elseif once this problem is solved. <?php mysql_connect(localhost, $db_username, $db_password); @mysql_select_db($db_database) or die("No connection"); $query = "Select * FROM table WHERE column='stuff' AND parent='1,2' ORDER BY id DESC LIMIT 10"; $query_result = mysql_query($query); $num_rows = mysql_num_rows($query_result); mysql_close(); ?> <?php for($i=0; $i< $num_rows; $i++){ //start a loop $stuff = mysql_result($query_result, $i, "column"); $row = mysql_fetch_assoc($query_result, $i); if($row['parent'] == 1) { $url = 'http://google.com'; } else { $url = 'http://www.bing.com'; } ?> My own first attempt at a if/then was 500. I got help on another site to redo it (new code shown here), but the new if/else always show the else (Bing). It was also at this time that I learned that "1,2" only showed 1. Hoping that this site is far more friendly than StackOverflow. .
×
×
  • 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.