PHP - Moved: Need Urgent Help In Php!
This topic has been moved to Miscellaneous.
http://www.phpfreaks.com/forums/index.php?topic=321874.0 Similar TutorialsThis topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=343748.0 This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=319414.0 (I am not an expert or even a begineer at PHP, so sorry if none of this makes sense) Right ok, I have an invitation form built and tested working correctly between a php page and a mysql database and got the mail function to work but now the mail function is throwing all emails into the junk mail folder of outlook. The user of the invitation form has to enter a valid email address (the form has its own validation for each textbox and email has been set to required email address). So I have been asked to set up a mailto instead of using the mail function (dont ask me why...) And I cant, for the life of me, figure out how to get this to work. What I have thought of so far is: Index.html (Invitation page) V sendinvitation.php (previously the page with the mail function) now includes a confirmation of the data being sent to the database and a button to go to the next php V sendmail.php (I want this to be able to get the data from the database and then open up the users email client and pre populate the email with the body text) Is this even possible? If not, is there a reason why the email keeps getting thrown into the junk mail. Please, any help would be most appreciated! EDIT: Let me explain a bit more, just re-read over and its very brief (this probably will be too) I want to invitation form to submit the users data to my database in mysql, then when the form as been submitted, to be able to then grab the data and pre populate an email using variables that are in the php linked to the database (Im guess the php would go from POST to GET?) Please help me with this: with this code i have only fetched out the subjects and i need to fetch out value for the following too from the database 1. GRADE 2. Contious Assessment: 3. Exam Scores: 4. Exam Scores 5. Weighted Average: 6. Last Term Cummulative: 7. Cumulative (c+d)/2: 8. Comment: but now i can only get the foreach work for subject alone.. $l=mysql_query("SELECT * FROM result WHERE school_id='$id' AND student_reg_id='$st'") or die (mysql_error()); if (mysql_num_rows($l) > 0) { while ($row = mysql_fetch_array($l)) {// $pwrlist[$row['ajax_result_id']]=$row['subject']; //$ } $numpwr = count($pwrlist); $thresh = 3; $maxcols = 18; $cols = min($maxcols, (ceil(count($pwrlist)/$thresh))); $percol = ceil(count($pwrlist)/$cols); $powerchk = ''; $i = 0; foreach ($pwrlist as $id => $pwr) { if (($i>0) && ($i%$percol == 0)) { $powerchk .= "</td>\n<td valign='top'>";//echo "<br>"; } $powerchk .= " <table width='280px' class='hovertable'> <tr> <td width='251px' height='34' align='left' valign='middle' bgcolor='#D6DFEB'><span class='style19'><font size=2px>$pwr</font></span></td> <td width='19px' align='left' valign='middle' bgcolor='#D6DFEB'><span class='style1'>GRADE:</span></td> <td width='20px' align='left' valign='middle' bgcolor='#FFFFFF'><span class='style13'>B3</span></td> </tr> <tr> <td height='34' colspan='3' align='left' valign='top' bgcolor='#FFFFFF'><span class='style20'>» (a) Contious Assessment: 80<br /> » (b) Exam Scores: 90<br /> » (c) Weighted Average: 168<br /> » (d) Last Term Cummulative: 78<br /> » (e) Cumulative (c+d)/2: 123 </span></td> </tr> <tr> <td height='20' colspan='3' align='left' valign='top' bgcolor='#FFFFFF'><span class='style17'>Comment: His is a responsible boy</span></td> </tr> </table><br>\n"; $i++; } } <?php $possibles[]; $alreadychosen[]; for ($i = 0; $i<20;$i++) $possibles =i+1; for (int $i = 0; $i<8; $i++) { $boolean= false; $randIndex=0; do { $randIndex = rand(1,20); for ($j = 0; $j< $i && !$hasInt; $j++) { if ($possibles[$randIndex] == $alreadyChosen[$j]) { $hasInt = true; } } } while ($hasInt); { $alreadyChosen = $possibles[randIndex]; echo($alreadyChosen); } for ($i = 0; $i<8;$i++) { if($alreadyChosen<10) { echo ('<a href="/mp/info130'+$i+'.htm"><img src="/mp/p130'+$i+'-1.jpg" height=180 width=120 align=left hspace=0 vspace=2 border=0 class=TopImages></a>'); } else if($alreadyChosen>10) { echo ('<a href="/mp/info13'+$i+'.htm"><img src="/mp/p13'+$i+'-1.jpg" height=180 width=120 align=left hspace=0 vspace=2 border=0 class=TopImages></a>'); it should select 8 images out of 20 but don't repeat please I am creating a member site and I need help with coding the database. Here go the code Code: [Select] <?php function connect(){ $DB_USER = "root"; $DB_PASSWORD = ""; $DB_HOST = "localhost"; $dbc = mysql_connect ($DB_HOST, $DB_USER, $DB_PASSWORD) or $error = mysql_error(); mysql_select_db("membership") or $error = mysql_error(); mysql_query("SET NAMES `utf8`") or $error = mysql_error(); if($error){echo "<!-- $error -->";}} function disconnect_data(){ @mysql_close($dbc); @mysql_close(); } ?>I am suppose to fill it in with my database info but idk what to fill in! help me please! where do i enter the info! hI for all Am developping a script that allow to each user (seperatly ) upload or download his files and list all files in categories (such music or photos...) but i can 't achieve that the main problem is to upload files to server and store them in data base also i have to list for each user his files seperatly when he log in any idea please Hello dear friends , I'm under attack huge attack from spam bots and i need your help 1) i've a form with input text and input submit 2) no way to add html cause using js banned any < or > ..ect 3) the spam attack now post html code but it stored into database after automatically < and > removed as i mention in (2) okay add to your note i can't add captcha cuase my website for kids Now please allow me to explain this idea and let me know if it ture or there is another way else more simple 1) i will add hidden input with value shows "IP Number Of Poster" 2) by that way i will know the IP of the spammer 3) i will use php and mysql to create database table and store the IPs of spamming i collect so that when that spammer hit my website again , will not be able to view input form. What do you think ! is it right or bad solution or is there any any way the bad idea is that spam is not sure human cause it is stupid and post something meaningless and not ture and fake urls like this Code: [Select] theuzgfnpbmi, [url=http://gdtuaemvkpif.com/]gdtuaemvkpif[/url], [link=http://rsxtnszcpceq.com/]rsxtnszcpceq[/link], http://awpfgwtvqkdm.com/" theuzgfnpbmi, [url=http://gdtuaemvkpif.com/]gdtuaemvkpif[/url], [link=http://rsxtnszcpceq.com/]rsxtnszcpceq[/link], http://awpfgwtvqkdm.com/" please help if you have any suggestion or method how to stop such spammers thank you so much hi for all am installing php security user mangement but i got some errors during install am using xampp 1.7.7 for windows but when i runed the script for the first time i got this message Warning: require_once(C:/xampp/htdocs/xampp/psumthemes/shared.js.php) [function.require-once]: failed to open stream: No such file or directory in C:\xampp\htdocs\xampp\psum\index.php on line 20Fatal error: require_once() [function.require]: Failed opening required 'C:/xampp/htdocs/xampp/psumthemes/shared.js.php' (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\xampp\psum\index.php on line 20() any ideas please my document root is C:/xampp/htdocs hey ive got a page that lists a users bank accounts...when the user chooses to update an account it goes to a new page where they can edit the details...when it goes to this new page it takes the user's ID and the account ID with it in the URL (http://localhost/oswp/bank/updateaccounts.php?id=34&cid=1) so i know these variables are correctly being transferred. now when the user has made their changes and clicked the update button it should update the database and then re-locate back to the original page listing all accounts...to get back to this page and show the correct accounts for that user i thaught i needed to take the ID from the URL...give it a variable...and use it in the URL back to the original page. so for example the variable and update sql and re-locate code would look like this. $cid = $_GET['cid']; //updating the table $result=mysql_query("UPDATE accounts SET accno='$accno', pin='$pin', type='$type', name='$balance', balance='$balance', active='$active' WHERE accid=$id"); header("location:accounts.php?id=$cid"); however currently when the user clicks update and it tries to relocate back to the original page its not getting the variable in the URL. (http://localhost/oswp/bank/accounts.php?id=) and im getting the errors: Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\uni\oswp\assignment\bank\accounts.php on line 26 's bank accounts Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\uni\oswp\assignment\bank\accounts.php on line 30 basically saying its expected a number up in the URL and its not finding one...but i dont know why...any ideas please its quite urgent. here is the relevant code for this section: Accounts.php: <a href="adminlogout.php">Logout</a><br /> <?php $id = $_GET['id']; if(!isset($_SESSION['myusername'])) { header("location:adminlogin.php"); } $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = ''; $db = 'bank'; $conn = mysql_connect($dbhost,$dbuser,$dbpass); mysql_select_db($db); $result = mysql_query("SELECT * FROM customer WHERE cusid=$id"); $row2 = mysql_fetch_array($result); echo $row2['name'] . "'s bank accounts" . "<br><br>"; $result2 = mysql_query("SELECT * FROM accounts WHERE cusid=$id"); echo "<form method='post' action='accounts.php?id=$id'>"; while($row = mysql_fetch_array($result2)) { echo "<input type='hidden' value='$row[accid]' name='accid'>" . $row['accno'] . $row['name'] . $row['type'] . $row['balance'] . $row['active'] . "<a href='updateaccount.php?id=$row[accid]&cid=$id'>Update</a>" . "<br>"; } echo "</form>"; ?> updateaccounts.php: $id = $_GET['id']; $cid = $_GET['cid']; if(!isset($_SESSION['myusername'])) { header("location:adminlogin.php"); } $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = ''; $db = 'bank'; $conn = mysql_connect($dbhost,$dbuser,$dbpass); mysql_select_db($db); if(isset($_POST['update'])) { $accno=$_POST['accno']; $pin=$_POST['pin']; $type=$_POST['type']; $name=$_POST['name']; $balance=$_POST['balance']; $active=$_POST['active']; // checking empty fields //if item field is empty if(empty($accno)) { echo "<font color='red'>account number field is empty.</font><br/>"; } elseif(empty($pin)) { echo "<font color='red'>pin field is empty.</font><br/>"; } elseif(empty($type)) { echo "<font color='red'>account type field is empty.</font><br/>"; } elseif(empty($name)) { echo "<font color='red'>account name field is empty.</font><br/>"; } elseif(empty($balance)) { echo "<font color='red'>balance field is empty.</font><br/>"; } elseif(empty($active)) { echo "<font color='red'>active field is empty.</font><br/>"; } else { //updating the table $result=mysql_query("UPDATE accounts SET accno='$accno', pin='$pin', type='$type', name='$balance', balance='$balance', active='$active' WHERE accid=$id"); header("location:accounts.php?id=$cid"); } } Ok all I need some help with this. I have been stuck for two days. Basically I have a form that asks a registrant their gender and age, then my script spits out a list of race categories they qualify for. The situation calls for the registrant to be able to register for any category YOUNGER than them, but not older. Screen Shot #1 shows my database setup (this can be changed if you have any better ideas...) that holds the race category information. Here is the sql statement I am using to pull a female racer information, where $race_age is their submitted age. "SELECT * from counts where female=1 and $race_age < age_end and $race_age > age_start" This works, but doesn't pull any categories YOUNGER Than their age. I'm stumpped Thanks for any help in advance. Okay so you may have noticed an earlier post from myself that problem have been fixed, Some background info, The website is currently on my test server so not connected to the internet. I have only been learning PHP for the last 3-4 days so I am fairly new to most things so please keep your explanations simple, The finished code here is being designed for use on large scale websites with a lot of users around 100,000+ per 24 hour period and therefor will need to be secure. Yet I have no idea how to do that, The script once finished will also be freely distributed and contributors will be fairly credited. I have some new problems that I need help fixing, So I am creating a PHP Blog connected to my MYSQL Database, Currently there is no admin backend that's a job for later but I do have the following files. index.php - This displays all blog posts for all my categorys news.php - This displays each blog post on there own config.php - This contains my server connect code I also have the following fields in my database articleid - Unique ID number of each blog post category - The category the blog post is in title - The title of each blog post body - The body of each post author - The name of the author date - date of posting But now I need to add some comments so can anyone please help out, The comments should only appear below the article on the 'news.php' page so I was hoping someone could write me a script to post and display the comments, (No login system needed I got that covered surprisingly.) if you can also give me a .sql file to add the needed tables to my database that would be greatly appreciated, Lastly would it be possible for someone to secure the script so it is invulnerable to SQL Injection attacks and any other form of attack that someone could pull off on the site. So bring on the code, Index.php Code: [Select] <?php include("config/config.php"); $data = mysql_query("SELECT * FROM blog ORDER by date ASC") or die(mysql_error()); while($row = mysql_fetch_array($data)) { echo "<table class='main'> <tr> <td> <a href='/news.php?articleid=" . $row['articleid'] . "' class='article_title'>" . $row['title'] . "</a> <p>" . $row['introduction'] . "</p></td><tr><td ALIGN='RIGHT' class='small'> Posted by:" . $row['author'] . ", on " . $row['date'] . ",</td></tr></table>"; } ?> Comments:I have removed all the junk out and left the basic script, news.php Code: [Select] <?php include("config/config.php"); $data = mysql_query("SELECT * FROM blog WHERE articleid = {$_GET['articleid']} ORDER by date ASC") or die(mysql_error()); while($row = mysql_fetch_array($data)) { echo "<table class='main'> <tr> <td> <a href='/news.php?articleid=" . $row['articleid'] . "' class='article_title'>" . $row['title'] . "</a> <p>" . $row['introduction'] . "</p></td><tr><td ALIGN='RIGHT' class='small'> Posted by:" . $row['author'] . ", on " . $row['date'] . ",</td></tr></table>"; } ?>Comments:So here's the complex bit if someone could please add the comments below the article here, Thanks again, Blaze, (Really bad PHP Programmer) Hey, I need a bit of help replacing some variables in a string. I know its done with preg_replace. Here is the string: Code: [Select] Header 1 <|header 2|> header 3 <b>header 4</b> I would like to get ONLY <|header 2|> from the above string. But "header 2" is variable so please its useless if the preg_replace isn't flexible to find whatever word is in there regardless. Thanks you. I have an array and I'd like to find the most popular value in the array. example. $arr = array(1,1,1,1,2,2,3,4,5,5,5,5,5,5,5,3,4,198,10293,1,2); I would like only display 5 please. What is all dependent on PHP?
I mean lets say I removed echo from phps source code.
Then I add function my_echo() which is the exact same code basically, what all would I need to update to allow my_echo() to be implemented correctly
Obviously I would need to modify every one of my php scripts on my webserver to replace echo with my_echo, but is there anything else?
I know i could just append my_echo to phps source, or modify the echo function itself, but this is conceptually and thats not the actual process I'm looking for right now.
Any insight would be greatly appreciated!
I have a shopping cart on my website with some minor errors. When you refresh the page it adds an extra quantity to the item when it shouldn't. Any help the code is below. $cart = $_SESSION['cart']; $action = $_GET['action']; switch ($action) { case 'add': if ($cart) { $cart .= ','.$_GET['id']; } else { $cart = $_GET['id']; } break; case 'delete': if ($cart) { $items = explode(',',$cart); $newcart = ''; foreach ($items as $item) { if ($_GET['id'] != $item) { if ($newcart != '') { $newcart .= ','.$item; } else { $newcart = $item; } } } $cart = $newcart; } break; case 'update': if ($cart) { $newcart = ''; foreach ($_POST as $key=>$value) { if (stristr($key,'qty')) { $id = str_replace('qty','',$key); $items = ($newcart != '') ? explode(',',$newcart) : explode(',',$cart); $newcart = ''; foreach ($items as $item) { if ($id != $item) { if ($newcart != '') { $newcart .= ','.$item; } else { $newcart = $item; } } } for ($i=1;$i<=$value;$i++) { if ($newcart != '') { $newcart .= ','.$id; } else { $newcart = $id; } } } } } $cart = $newcart; break; } $_SESSION['cart'] = $cart; This website has been great so far. Whenever I post a question, I get answer within few minutes. I have another question today related to PHP pagination. My search page basically allows users to view users others users in a specific country. Basically, there is are two html drop downs on the search page. First one allows you to select gender (male or female) and other one allows you to select country. After the search button is pressed, it displays all the usernames of males in that country. my search page's url looks something like: Code: [Select] http://localhost/search.php?gender=Male&country=Canada&searchbutton=Search[/b] I want to add pagination to this script. the search form has method=GET and 3 input options. one is gender and the other one is country and the last one is pageNum which is hidden. how can i add pagination to this??? Ok my input is an array. $episode_number = array('2','99'...'004'); where "..." is any amount of values. My aim is to take these values and format them so that they ALWAYS have 3 characters in them by adding Zero's to the beginning. So 2 will become 002 and 99 will become 099 and 004 will remain 004. I have attempted my code he for($i=0; $i<$numberlinks; $i++) { $thecount = strlen($episode_number[i]); if($thecount == '1'){ $episode_number[i] == '00'.$episode_number[i].''; } elseif($thecount == '2'){ $episode_number[i] == '0'.$episode_number[i].''; } else { $episode_number[i] == $episode_number[i]; } echo $episode_number[i].'<br />'; } The above output is 2 <br /> tags. But when i add on osme code to it: for($i=0; $i<$numberlinks; $i++) { $thecount = strlen($episode_number[i]); if($thecount == '1'){ $episode_number[i] == '00'.$episode_number[i].''; } elseif($thecount == '2'){ $episode_number[i] == '0'.$episode_number[i].''; } else { $episode_number[i] == $episode_number[i]; } echo $episode_number[i].'<br />'; } $query2[] = ("INSERT INTO episodes (anime_id,anime, username, userid, episode_name, episode_number, manga_chapter_link, moderated) VALUES ('".$anime_id[$i]."', '".$anime[$i]."', '".$username."', '".$userid."', '".clean($episode_name[$i])."', '".clean($episode_number[$i])."', '".clean($manga_chapter_link[$i])."','1')"); } foreach ($query2 as $query){ mysql_query($query) or die (mysql_error()); echo "<span style='color:green'>Added sucessfully <b>Episode ".++$one."</b> </span><br/>"; } the output is the input, ie, 02 remains 02 and not 002. can anyone help me or give me a method that works? |