PHP - Use Information Gathered In Php In Html
Hello i'm a quite the novice when in comes to php so bear with me.
I have information stored in php variables, and i'm wondering what is the best way to get that information to a html page to be put a a table or something. essentially I don't want to include the php code on the html page, but still somehow execute the php and get the information the the html page. Similar TutorialsThis is a tough one to summarize - especially in the Subject?! I need to insert a Comment which consists of: * article_id * member_id * body * status * created_on * approved_on * updated_on Only the "body" field is gathered from my "Add a Comment" form, and everything else either comes from the $_SESSION or from NOW() I am wondering if it would be easier to do Error-Handling and what-not if I created an Input for at least the first 4 fields above and populated the "Value" of those fields that already have values (e.g. "member_id")?? Then when the user clicks "Add a Comment", I can check all of the values in $_POST and handle everything in a uniform way, if you follow my new thinking?! Debbie Have never done this before, but I'm sure many of you have. What I am trying to do is take the information that the user fills out in this form and when they hit submit, it will be displayed into a html table on the next page. I don't need someone to do the entire table for me, just looking for some help to get started and a general idea of what to do. Here is my code for my form that I have created... Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Lab 4</title> </head> <body> <?php ?> <form method="POST" action="lab4form.php"> <label for="first_name">First Name:</label> <input type="text" id="first_name" name="first_name" /><br /> <label for="last_name">Last Name:</label> <input type="text" id="last_name" name="last_name" /><br /> <label for="coverage_amount">Coverage Amount:</label> <input type="text" id="coverage_amount" name="coverage_amount" /><br /> <label for="gender">Gender:</label> <br> <input id="male" type="radio" value="radiobutton" name="male" /> <label for="male">Male</label> <input id="female" type="radio" value="radiobutton" name="female" /> <label for="female">Female</label> <br /> <br> <label for="Age">Age:</label> <input type="text" id="age" name="age" /><br /> <br> <label for="health">Health Conditions</label> <br /> <input type="checkbox" name="health" value="heart" /> <label for="health">Heart Disease</label><br /> <input type="checkbox" name="health" value="diabetes" /> <label for="health">Diabetes</label><br /> <input type="checkbox" name="health" value="blood" /> <label for="health">High Blood Pressure</label><br /> <input type="checkbox" name="health" value="Smoker" /> <label for="health">Smoker</label><br /> <input type="checkbox" name="health" value="lung" /> <label for="health">Lung disease</label><br /> <FORM METHOD=POST ACTION="lab4form.php"> <P>Employment Status<BR> <SELECT NAME="employment"> <OPTION VALUE="lab4form.php">Unemployed <OPTION VALUE="lab4form.php">Full-Time <OPTION VALUE="lab4form.php">Part-Time <OPTION VALUE="lab4form.php">Student </SELECT><br /> <br> <label for="comments">Comments</label> <input type="text" id="comments" name="comments"/><br /> <br> <input type="submit" value="Add User" name="btn_add" /> </form> </body> </html> Greetings, I am trying to create a basic booking system, for example there may be 3 events that a user can book. If the user clicks 'Book Now' on Event #1 I need it to take them to the HTML/PHP booking form with the information already entered that is relevant to Event #1 (Or whatever event they choose), such as the event name, time, date etc I know how to create a contact form etc, its just the carrying of the information over to the form I dont know how to do. Does anyone know if this is possible/ how it could be achieved? Any help will be much appreciated, Thanks! This is my school project "tv-info" that uses simple_html_dom.
My tv.php
// scrape a tag $html = file_get_html("http://www.ampparit.com/tv-opas?g=peruskanavat-1"); foreach($html->find($tag) as $e) $main = $e->plaintext . '<br />'; //plain $html = file_get_html("http://www.ampparit.com/tv-opas?g=peruskanavat-1"); echo $html->find('[table class="fullwidth"]', 1)->innertext.'</table>';So my problem is how I can remove some tags in this page? It shows too much things and what I want it is show only tv-table.. There is inside this this tv table like this: <table class="content-layout"> <tr> <td id="content" class="content"><div class="submenu-top-container"> <form action="haku" class="right" style="margin-top: 5px;"> <div class="input-wrapper"> <input type="text" name="q" placeholder="Kirjoita hakusana..." style="width: 165px;"><input type="hidden" name="t" value="tv"><button>Hae</button> </div> </form> <div class="submenu-top-item selected"> <a href="/tv-opas" class="submenu-top-item-link">Ohjelmaopas</a> </div> <div class="submenu-top-item "> <a href="/tv-opas?g=suosikkikanavat" class="submenu-top-item-link">Suosikkikanavat</a> </div> <div class="submenu-top-item "> <a href="/tv-opas?g=peruskanavat-1&ss=movies" class="submenu-top-item-link">Elokuvat</a> </div> <div class="submenu-top-item "> <a href="/tv-opas?g=peruskanavat-1&ss=sports" class="submenu-top-item-link">Urheilu</a> </div> <div class="submenu-top-item "> <a href="/tv-opas?g=peruskanavat-1&ss=favorites" class="submenu-top-item-link">Suosikit</a> </div> </div>Thank you if someone can help me! And if someone ask me to use tvrage, I don't because I'm from Finland and there is no support for Finnish tv-series etc.. Not so much of a programming problem as such but if I add the ability to recover accounts via IP address, is it possible to spoof an IP address? Is it a bad idea to automatically allow a user to reset a password if their IP (according to PHP) matches the IP that created the account? Can someone help me send a value in a form to another page...(value=$emailhim) This is the sending page Code: [Select] <?php $emailit = $_GET['emailusr']; echo" <table width='602' height='283' border='0'> <form action='emailuser.php' method='POST'> <tr> <td width='210' height='13'>You Are Contacting:</td> <td width='382' align='left'><input type='text' name='emailnow' value='$emailit' disabled='disabled'/></td> </tr> <tr> <td width='210' height='14'>Book Title:</td> <td width='382' align='left'><input type='text' name='book' maxlength='25'/></td> </tr> <tr> <td width='210' height='14'>ISBN Number: </td> <td align='left'><input type='text' name='isbn' maxlength='25'/></td> </tr> <tr> <td width='210' height='15'>My Email:</td> <td align='left'><input type='text' name='myemail' maxlength='25'/></td> </tr> <tr> <td height='123' align='left'>Question/Comment:</td> <td><textarea name='question' cols='60' rows='5'></textarea></td> </tr> <tr> <td colspan='2' align='center'><input type='submit' name='submit' value='Send' /></td> </tr> </form> </table>" ?> This is the receiving page Code: [Select] $book = $_POST['book']; $isbn = $_POST['isbn']; $myemail = $_POST['myemail']; if ($_POST['submit']) { //existance check if ($book) { if ($isbn) { if ($myemail) { $question = $_POST['question']; $username = $_SESSION['username']; $emailhim = $_POST['emailnow']; //connect to database $connect = mysql_connect("db","user","pass") or die("Not connected"); mysql_select_db("user") or die("could not log in"); //grab email from database $query = "SELECT * FROM desiredusers WHERE username='$emailhim'"; $result = mysql_query($query); while($row = mysql_fetch_array($result)) //set email to variable name $person = $row['email']; //set SMTP //$server = "smtp.gmail.com"; //ini_set("SMTP",$server); //setup variables $to = "butters4life24@gmail.com"; $subject = "$username has a question"; $body = "This is an email from $username\n\n Their question regarding $book, ISBN#: $isbn\n is $question\n\n\n This is the email address $username would like you to contact him on: $myemail\n\n\n"; $headers = "From: $myemail"; mail($to, $subject, $body, $headers); echo "$person"; echo "$emailhim"; } else die('Please fill in My Email. This will be the email address that the user that you are contacting will email you back on. (*note if you do not put in your correct email the person that you emailed will have no way of emailing you back)'); } else die('Please fill in ISBN Number.'); } else die('Please fill in Book Title.'); } ?> Is there a good how to out there on how to create a code that will tell me where a page visitor is from? Similiar to google analytics, I'd like to find out where a visitor is from but I need this information before the page loads. I've tried googling but all I come up with are sites that offer the service if I sign up with them. Also, I have a list of zip codes / cities in an excel spreadsheet .. I'd like to get this into a db table but don't want to type each one out for the next month. How could I do this? My host is godaddy on a linux box with mysql 5.X if that helps. Thank you i have had a difficult time trying to work this out.I need to do some pattern matching for certain urls and retrieve information from it. For example, $url=http://www.test.com/showpic.php?do=showpic&u=89165&a=34933 if $url contains the value showpic.php,then i need to retrieve the following { $u=value of u(i.e. 89165 in this case) $a=value of a(i.e. 34933 in this case) } else do nothin.. the format of the url will always be the same as above if it contains showpic.php Dear All, How can I get information that return from this array Array ( [0] => Array ( [id] => 5 [t_test_date] => 2021-02-11 [t_test_number] => 1 [t_uid] => 202102110001 [t_test_type] => 1 [t_status_id] => 4 [t_test_result_pcr] => 1 [t_test_result_rdt] => 0 [t_test_time] => 2021-02-11 11:39:00 [t_report_date] => [p_first_name] => tesdt [p_last_name] => tesdt [p_gender] => 0 [p_nationality] => [p_date_birth] => [p_passport_no] => [p_personal_id] => [p_issue_country] => [p_date_expiry] => [phone] => [email] => [t_price] => 0 [p_valid] => 1 [created_date] => 2021-02-11 [modified_date] => 2021-02-11 11:40:18 [t_status_type] => ຂັ້ນຕອນທີ່ 4. ອອກການຢັ້ງຢືນ [t_status_typeEng] => Stage 4. Certificate Issued [t_status] => 4. ຢັ້ງຢືນແລ້ວ [t_statusEng] => 4. Issued [test_time] => 11/02/2021 11:39 ) [1] => Array ( [id] => 7 [t_test_date] => 2021-02-11 [t_test_number] => 3 [t_uid] => 202102110003 [t_test_type] => 2 [t_status_id] => 4 [t_test_result_pcr] => 1 [t_test_result_rdt] => 1 [t_test_time] => 2021-02-11 18:38:00 [t_report_date] => [p_first_name] => Hhh [p_last_name] => Tttt [p_gender] => 0 [p_nationality] => [p_date_birth] => [p_passport_no] => [p_personal_id] => [p_issue_country] => [p_date_expiry] => [phone] => [email] => [t_price] => 0 [p_valid] => 1 [created_date] => 2021-02-11 [modified_date] => 2021-02-11 18:38:51 [t_status_type] => ຂັ້ນຕອນທີ່ 4. ອອກການຢັ້ງຢືນ [t_status_typeEng] => Stage 4. Certificate Issued [t_status] => 4. ຢັ້ງຢືນແລ້ວ [t_statusEng] => 4. Issued [test_time] => 11/02/2021 18:38 ) );
i need someone tohelp me build a script that will fetch infomration on a website, and automatically input it into a database. I know its possible i have reaserached it, and it can be done by using the $curl php technique. it is not a coplicated job i just dont have time for it. i need the script to access diffrent website, at a specific time of day. i want the sript to automaticlly fetch the data from each site at a spesific time during the day. i really dont know where to start... any help will be apprecited. I managed to come up with this, but it does not do what i want Code: [Select] <?php class tagSpider { var $crl; // this will hold our curl instance var $html; // this is where we dump the html we get var $binary; // set for binary type transfer var $url; // this is the url we are going to do a pass on function tagSpider() { $this->html = ""; $this->binary = 0; $this->url = ""; } function fetchPage($url) { $this->url = $url; if (isset($this->url)) { $this->ch = curl_init (); // start cURL instance curl_setopt ($this->ch, CURLOPT_RETURNTRANSFER, 1); // this tells cUrl to return the data curl_setopt ($this->ch, CURLOPT_URL, $this->url); // set the url to download curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION, true); // follow redirects if any curl_setopt($this->ch, CURLOPT_BINARYTRANSFER, $this->binary); // tell cURL if the data is binary data or not $this->html = curl_exec($this->ch); // grabs the webpage from the internet curl_close ($this->ch); // closes the connection } } function parse_array($beg_tag, $close_tag) // this function takes the grabbed html and picked out the pieces we want { preg_match_all("($beg_tag.*$close_tag)siU", $this->html, $matching_data); // match data between specificed tags return $matching_data[0]; } } ?> Working on a music/video project. Uploaded tracks are stored in user files and product info is stored to DB. What I've been trying to figure out is getting the product information directly from the upload, much like you see in the shot attached. As I haven't had success with that, I've been trying to get the duration of a track using this code. Code: [Select] $fp = fopen($file, 'r'); $size_in_bytes = filesize($file); fseek($fp, 20); $rawheader = fread($fp, 16); $header = unpack('vtype/vchannels/Vsamplerate/Vbytespersec/valignment/vbits', $rawheader); $tsec = number_format($size_in_bytes/$header['bytespersec'],2); $minutes = intval(($tsec / 60) % 60); $seconds = intval($tsec % 60); $sec="$minutes".":".($seconds<10 ? "0$seconds" : "$seconds");This is working fine when file names are plain text, however it fails when when there are commas or brackets. I don't know if the code can be adjusted to work with these file names or I need to take a different approach. Code: [Select] examples $file ="A cool track, once again"; $file ="A cool track (once again)"; As artists can be picky about their music, I don't want to rename their tracks, but really we shouldn't even have spaces in the names. I could save original name to DB and rename the file, but not sure about restoring original when it come time to download the file. In any case, I hope you understand my problem and can offer some advice. Thanks. Hi there, How to work out?? We have our web page where we enter our client information.. Part A Than same information we have to enter third party web page. Part B How can we transfer same information fr our web page to third party web page like .. Input in text field instead of type each box… Please if someone can guide us or any link to follow… Hello, I'm writing an application that will have to interact with my webserver and it will be using php to input data into the database and retrieve from as well. However, I'm not sure what is the best approach on securing my database from people sniffing while using my application. The only thing that I can do that is coming to mind is try to use a unique key as a password and have one of my GET vars be that password, but that is easily sniff-able. What can I do to secure my database and prevent people from filling up my databases if they sniff out my password key? Is there any kind of encryption I can use that will defeat this? Hi all, I have an array $n[] and have made a DB query with fetch_array ($result[]). Now I'm trying to get the information out of the $result[] with $n[] so I made the following and it doesn't work. I checked if they're filled and they are and when I enter in the $result[] array with hardcoded info I do get what I need but I need it trough the array... Can anyone help me out?? Thnx Ryflex $sql = "SELECT * FROM units WHERE member_id = '$member_ID'"; $result = mysql_fetch_array(mysql_query($sql)) or die("Could not find amount of troops"); $troop_one = $result['$n[0]']; $troop_two = $result['$n[1]']; $troop_three = $result['$n[2]']; $troop_four = $result['$n[3]']; I am trying to pull in computer information using PHP for program compatibility and want to know if it is possible and if so, what functions to use. Hi guys, hopefully someone can help walk me through this.
Basically I want to:
1) Send parameters to remote sites form
2) Receive information/failsafe
3) display data
Sounds easier than it is, can someone explain to a php newb how this can be done?
Site will be given appropriate credit.
How can i use return to output more than one row of information? i would like to merge the results from multiple SQL rows into one string somehow so that I can return them through a function. Any ideas how i can do this? here is my current code: $query = exec_mysql_query("SELECT * FROM av_genres WHERE id = $cid ORDER BY name DESC"); while ($row = mysql_fetch_assoc($query)) { return $row['name']; } if i use 'echo' it displays all results as i want it to but it doesnt output in the correct place for some reason. any ideas? hey guys, I am looking for a way to find out information about the referring site a user clicked through to get to my site. Is that possible and if so, How? Ideally, I am looking for: Site Domain Name The referral URL Meta information of the page I believe I can get this stuff from analytics software, but I am trying to think of a way to do it in my own script. Is it possible and does anyone have any ideas to point me in the right direction? thanks I'm trying to create a profile page that an unregistered user can view when he enters in the username into the url (e.g. http://localhost/username) Just recently got my mode_rewrite going (tried and tested), but I don't get the users information coming up in the page. Am I going about this the right way? This is what the page shows: The requested page was: Notice: Undefined variable: name_id in C:\x\xampp\htdocs\pages\profile.php on line 27 Notice: Undefined variable: name in C:\x\xampp\htdocs\pages\profile.php on line 28 Notice: Undefined variable: password in C:\x\xampp\htdocs\pages\profile.php on line 29 profile.php <?php include 'db.inc.php'; $db = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD) or die ('Unable to connect. Check your connection parameters.'); mysql_select_db(MYSQL_DB, $db) or die(mysql_error($db)); $query = 'SELECT name_id, name, password FROM user WHERE name = "' . mysql_real_escape_string($_GET['name'], $db) . '"'; $result = mysql_query($query, $db) or die(mysql_error()); ?> <html> <head> <title> <?php echo $name; ?> </title> </head> <body> <p> The requested page was: <?php echo $name_id; echo $name; echo $password; ?> </p> </body> </html> I've been messing around with this for awhile so I'm going to hit the sack. Hey guys, I've searched on Google for this and have had no luck, and you guys have been EXTREMELY helpful with a few of my previous questions! Alright the error I get is: Warning: Cannot modify header information - headers already sent by (output started at /****/header.php:6) in /***/*login.php on line 65 Errr.. After I posted this I saw the Sticky regarding Header posts.. I read the post and cannot find where the issue is with this.. The PHP code comes before the form information, am I missing something? My login.php script is: Code: [Select] <?php include("header.php"); mysql_connect("10.6.186.84", "gilmdiniz", "Gil19471947") or die(mysql_error()); mysql_select_db("gilmdiniz") or die(mysql_error()); if(isset($_COOKIE['ID_my_site'])) { $username = $_COOKIE['ID_my_site']; $pass = $_COOKIE['Key_my_site']; $check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error()); while($info = mysql_fetch_array( $check )) { if ($pass != $info['password']) { } else echo "SUP";//header($hdir."files.php"); } } if (isset($_POST['submit'])) { if(!$_POST['username'] | !$_POST['pass']) die('<center>You did not fill in a required field! <br /> <a href="'.$hdir.'login.php"> Back to Login </a> </center>'); if (!get_magic_quotes_gpc()) $_POST['email'] = addslashes($_POST['email']); $check = mysql_query("SELECT * FROM users WHERE username = '".$_POST['username']."'")or die(mysql_error()); $check2 = mysql_num_rows($check); if ($check2 == 0) die('<center>This username does not exist in our database, sorry. <br /> <a href="'.$hdir.'login.php"> Back to Login </a> </center>'); while($info = mysql_fetch_array( $check )) { $_POST['pass'] = stripslashes($_POST['pass']); $info['password'] = stripslashes($info['password']); $_POST['pass'] = md5($_POST['pass']); if ($_POST['pass'] != $info['password']) die('<center>Incorrect password, please try again. <br /> <a href="'.$hdir.'login.php"> Back to Login </a> </center>'); else { $_POST['username'] = stripslashes($_POST['username']); $hour = time() + 3600; setcookie(ID_my_site, $_POST['username'], $hour); setcookie(Key_my_site, $_POST['pass'], $hour); echo "SUP";//header($hdir."files.php"); } } } else { ?> <center> <a href="<?php echo $hdir .'index.php'; ?>"> Back to Home </a> <table border="1"> <tr><td> <center><h2>Login Information</h2></center> </td></tr> <tr><td> <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post"> <table border="0"> <tr><td> Username: </td><td> <input type="text" name="username" maxlength="40"> </td></tr> <tr><td> Password: </td><td> <input type="password" name="pass" maxlength="50"> </td></tr> <tr><td colspan="2" align="right"> <input type="submit" name="submit" value="Login"> </td></tr> </table> </form> </td></tr> </table> </center> <?php } ?> and my header.php script is: Code: [Select] <?php $hdir = "http://www.ondemandagents.com/NewSite_ALPHA/"; ?> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <link rel="stylesheet" type="text/css" href="<?php echo $hdir .'style.css'; ?>" /> </head> <body> <table width="920" cellspacing="0" cellpadding="10" border="0" align="center"> <tr> <td class="bodyline"> <table align="center" border="0" width="635" height="121" background="<?php echo $hdir .'images/logo.png'; ?>"> <tr> <td height="69"> <table border="0" width="635" height="106"> <tr> <td width="800" height="70"> </td> <td width="600" height="70"> </td> </tr> <tr> <td width="400" height="18"> </td> <td width="600" height="18"> <a href="<?php echo $hdir .'index.php'; ?>" style="text-decoration: none"> <img src="<?php echo $hdir .'images/icon_mini_home.gif'; ?>" width="12" height="13" border="0" alt="Home" hspace="3" /> <font face="Arial" color="#FFFFFF" size="2">Home </font></a> <a href="<?php echo $hdir .'files.php'; ?>" style="text-decoration: none"> <img src="<?php echo $hdir .'images/icon_mini_files.gif'; ?>" width="12" height="13" border="0" alt="Files" hspace="3" /> <font face="Arial" color="#FFFFFF" size="2">Files </font></a> <a href="<?php echo $hdir .'admin.php'; ?>" style="text-decoration: none"> <img src="<?php echo $hdir .'images/icon_mini_login.gif'; ?>" width="12" height="13" border="0" alt="Administration" hspace="3" /> <font face="Arial" color="#FFFFFF" size="2">Administration</font></a> </td> </tr> </table> </td> </tr> </table> </td> </tr> </table> I have been using a header file in all my pages and scripts so far so that I wouldn't have to keep typing repetitive code.. Help is MUCH appreciated! Thanks in advance guys |