PHP - No Record Shown When Editing Profile In Webpage
Hi,
I need some help here! I am working out a webpage which will allow administrators to edit tutors' profile online. From index.php, admin will click on the link to get into individual tutor's record, and it will direct them to viewprofile.php. In viewprofile.php, admin can choose to edit the tutor's profile by hitting the Edit Profile button. (Which is in viewprofile.jpg attachment) Here is the issue, when admin enters into editprofile.php, there is no record of the tutor, it seems like the records/details of the tutor is not brought forward into editprofile.php. (View editprofile.jpg for an example) I suspect it may be due to my $_GET statement in editprofile.php? That may have caused me not being able to retrieve the records? Appreciate any help. Thanks viewprofile.php Code: [Select] <?php // Start the session require_once('inc/php/db_search/admin_startsession.php'); // Insert doctype and header include 'inc/php/db_search/db_doctype.php'; require_once('inc/php/db_search/header_admin.php'); // Make sure the user is logged in before going any further. if (!isset($_SESSION['admin_id'])) { echo '<p class="login">Please <a href="admin_login.php">log in</a> to access this page.</p>'; exit(); } ?> <?php require_once('inc/elements/connectvars.php'); ?> <?php // Connect to the database $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); $query = "SELECT name, nric, gender, address, hse_phone, hp FROM tutor_profile WHERE tutor_id = '" . $_GET['tutor_id'] . "'"; $data = mysqli_query($dbc, $query); if (mysqli_num_rows($data) == 1) { // The user row was found so display the user data $row = mysqli_fetch_array($data); echo '<table>'; if (!empty($row['name'])) { echo '<tr><td class="label">Name:</td><td>' . $row['name'] . '</td></tr>'; } if (!empty($row['nric'])) { echo '<tr><td class="label">NRIC:</td><td>' . $row['nric'] . '</td></tr>'; } if (!empty($row['last_name'])) { echo '<tr><td class="label">Last name:</td><td>' . $row['last_name'] . '</td></tr>'; } if (!empty($row['gender'])) { echo '<tr><td class="label">Gender:</td><td>'; if ($row['gender'] == 'M') { echo 'Male'; } if ($row['gender'] == 'F') { echo 'Female'; } echo '</td></tr>'; } echo '</table>'; if (isset($_GET['tutor_id'])) { echo '<p>Would you like to <a href="editprofile.php">edit your profile</a>?</p>'; } } // End of check for a single row of user results else { echo '<p class="error">There was a problem accessing your profile.</p>'; } mysqli_close($dbc); ?> <?php // Insert the page footer require_once('inc/elements/footer.php'); ?> editprofile.php Code: [Select] <?php // Start the session require_once('inc/php/db_search/admin_startsession.php'); // Insert doctype and header include 'inc/php/db_search/db_doctype.php'; require_once('inc/php/db_search/header_admin.php'); // Make sure the admin is logged in before going any further. if (!isset($_SESSION['admin_id'])) { echo '<p class="login">Please <a href="admin_login.php">log in</a> to access this page.</p>'; exit(); } ?> <?php require_once('inc/elements/connectvars.php'); ?> <?php // Connect to the database $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); if (isset($_POST['submit'])) { // Grab the profile data from the POST $name = mysqli_real_escape_string($dbc, trim($_POST['name'])); $nric = mysqli_real_escape_string($dbc, trim($_POST['nric'])); $gender = mysqli_real_escape_string($dbc, trim($_POST['gender'])); $error = false; // Update the profile data in the database if (!$error) { if (!empty($name) && !empty($nric) && !empty($gender)) { $query = "UPDATE tutor_profile SET name = '$name', nric = '$nric', gender = '$gender' WHERE tutor_id = '" . $_GET['tutor_id'] . "'"; mysqli_query($dbc, $query); // Confirm success with the user echo '<p>Your profile has been successfully updated. Would you like to <a href="viewprofile.php">view your profile</a>?</p>'; mysqli_close($dbc); exit(); } else { echo '<p class="error">You must enter all of the profile data (the picture is optional).</p>'; } } } // End of check for form submission else { // Grab the profile data from the database $query = "SELECT name, nric, gender FROM tutor_profile WHERE tutor_id = '" . $_GET['tutor_id'] . "'"; $data = mysqli_query($dbc, $query); // The user row was found so display the user data if (mysqli_num_rows($data) == 1) { $row = mysqli_fetch_array($data); if ($row != NULL) { $name = $row['name']; $nric = $row['nric']; $gender = $row['gender']; } else { echo '<p class="error">There was a problem accessing your profile.</p>'; } } } mysqli_close($dbc); ?> <form enctype="multipart/form-data" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo MM_MAXFILESIZE; ?>" /> <fieldset> <legend>Personal Information</legend> <label for="firstname">First name:</label> <input type="text" id="firstname" name="firstname" value="<?php if (!empty($name)) echo $name; ?>" /><br /> <label for="lastname">Last name:</label> <input type="text" id="lastname" name="lastname" value="<?php if (!empty($nric)) echo $nric; ?>" /><br /> <label for="gender">Gender:</label> <select id="gender" name="gender"> <option value="M" <?php if (!empty($gender) && $gender == 'M') echo 'selected = "selected"'; ?>>Male</option> <option value="F" <?php if (!empty($gender) && $gender == 'F') echo 'selected = "selected"'; ?>>Female</option> </select><br /> </fieldset> <input type="submit" value="Save Profile" name="submit" /> </form> <?php // Insert the page footer require_once('inc/elements/footer.php'); ?> Similar TutorialsHi all, I am currently facing a problem, if you look at 'viewprofile.jpg' attachment, you can see that there is an uploaded profile picture. However when I click to edit the profile, the picture is missing (editprofile.jpg), I am just wondering what went wrong? Can someone guide me in troubleshooting this problem? Code: [Select] <?php if (isset($_POST['submit'])) { // Validate and move the uploaded picture file, if necessary if (!empty($new_picture)) { if ((($new_picture_type == 'image/gif') || ($new_picture_type == 'image/jpeg') || ($new_picture_type == 'image/pjpeg') || ($new_picture_type == 'image/png')) && ($new_picture_size > 0) && ($new_picture_size <= CT_MAXFILESIZE)) { //0 indicates a success, other values indicate failure if ($_FILES['file']['error'] == 0) { // Move the file to the target upload folder $target = CT_UPLOADPATH . basename($new_picture); if (move_uploaded_file($_FILES['new_picture']['tmp_name'], $target)) { // The new picture file move was successful, now make sure any old picture is deleted if (!empty($old_picture) && ($old_picture != $new_picture)) { @unlink(CT_UPLOADPATH . $old_picture); } } else { // The new picture file move failed, so delete the temporary file and set the error flag @unlink($_FILES['new_picture']['tmp_name']); $error = true; echo '<p class="error">Sorry, there was a problem uploading your picture.</p>'; } } } else { // The new picture file is not valid, so delete the temporary file and set the error flag @unlink($_FILES['new_picture']['tmp_name']); $error = true; echo '<p class="error">Your picture must be a GIF, JPEG, or PNG image file no greater than ' . (CT_MAXFILESIZE / 1024). '</p>'; } } // Grab the profile data from the POST $name = mysqli_real_escape_string($dbc, trim($_POST['name'])); $nric = mysqli_real_escape_string($dbc, trim($_POST['nric'])); $gender = mysqli_real_escape_string($dbc, trim($_POST['gender'])); $old_picture = mysqli_real_escape_string($dbc, trim($_POST['old_picture'])); $new_picture = mysqli_real_escape_string($dbc, trim($_FILES['new_picture']['name'])); $new_picture_type = $_FILES['new_picture']['type']; $new_picture_size = $_FILES['new_picture']['size']; list($new_picture_width, $new_picture_height) = getimagesize($_FILES['new_picture']['tmp_name']); $error = false; // Update the profile data in the database if (!$error) { if (!empty($name) && !empty($nric) && !empty($gender)) { $query = "UPDATE tutor_profile SET name = '$name', nric = '$nric', gender = '$gender' WHERE tutor_id = '" . $_GET['tutor_id'] . "'"; mysqli_query($dbc, $query) or die(mysqli_error($dbc)); // Confirm success with the user echo '<p>Your profile has been successfully updated. Would you like to <a href="viewprofile.php?tutor_id=' . $_GET['tutor_id'] . '">view your profile</a>?</p>'; mysqli_close($dbc); exit(); } else { echo '<p class="error">You must enter all of the profile data (the picture is optional).</p>'; } } } // End of check for form submission else { // Grab the profile data from the database $query = "SELECT name, nric, gender FROM tutor_profile WHERE tutor_id = '" . $_GET['tutor_id'] . "'"; $data = mysqli_query($dbc, $query) or die(mysqli_error($dbc)); // The user row was found so display the user data if (mysqli_num_rows($data) == 1) { $row = mysqli_fetch_array($data); if ($row != NULL) { $name = $row['name']; $nric = $row['nric']; $gender = $row['gender']; } else { echo '<p class="error">There was a problem accessing your profile.</p>'; } } } mysqli_close($dbc); ?> <form enctype="multipart/form-data" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo CT_MAXFILESIZE; ?>" /> <ul id="tabSet_ep"> <li><a href="#panel1">Personal Profile</a></li> <li><a href="#panel2">Qualifications</a></li> <li><a href="#panel3">Tutor\'s Comments/Commitment</a></li> <li><a href="#panel4">Tutoring Levels/Subjects</a></li> </ul> <!--Personal Profile--> <div id="panel1"> <label for="new_picture">Pictu </label> <input type="file" id="new_picture" name="new_picture" /> <?php if (!empty($old_picture)) { echo '<img class="profile" src="' . CT_UPLOADPATH . $old_picture . '" alt="Profile Picture" />'; } ?><br /> <label for="firstname">First name:</label> <input type="text" id="firstname" name="firstname" value="<?php if (!empty($name)) echo $name; ?>" /><br /> <label for="lastname">Last name:</label> <input type="text" id="lastname" name="lastname" value="<?php if (!empty($nric)) echo $nric; ?>" /><br /> <label for="gender">Gender:</label> <select id="gender" name="gender"> <option value="M" <?php if (!empty($gender) && $gender == 'M') echo 'selected = "selected"'; ?>>Male</option> <option value="F" <?php if (!empty($gender) && $gender == 'F') echo 'selected = "selected"'; ?>>Female</option> </select><br /> </div> <input type="submit" value="Save Profile" name="submit" /> </form> So i have this CMS that is used by lots of users and generally they do have rights to edit each others article. So now i'm thinking how can i at least warn them that somebody else is already editing it. Just that. maybe with sessions? but what happens when a user just closes the windows, will it destroy it. i taught about storing the value to mySQL but again what if the user closes the windows and so on. i never did this and i could use a boost. thanks guys try { echo "<br>"; foreach($dbh->query("SELECT * FROM test_shot WHERE sold=1 ORDER BY year ASC") as $row) { if($row['picture'] != "" && $row['picture'] != null) { echo "<div class='image-holder'><img src ='".$row['picture']."' width=300px /><br>"; } if($row['year'] != "" && $row['year'] != null) { echo $row['year']; } if($row['description'] != "" && $row['description'] != null) { echo $row['description']; } if($row['sold'] == 1) { echo "<img src='images/sold1.png'><br>";//Add your image code here } elseif ($row['sold'] == 0) { echo "</div><br>"; } } } catch (PDOException $e) { print $e->getMessage(); } ?>
hi, i have the code below where it shows the images in connection with a reference. in my img table i only have two rows but the code below keeps showing it 7 times can you please help me? <table width=200> <div id="wrapper"> <!-- Content area --> <div id="content"> <!-- We will be working inside these tags --> <div id="gallery"> <?php $images=mysql_query("SELECT img.id, img.refimage, img.image, img.thumb, users.users_id FROM img, users WHERE img.refimage='$ref' AND users_id='$user_id'"); echo '<table width="40">'; while($row = mysql_fetch_array($images)) { $image=$row['image']; $thumb=$row['thumb']; echo '<div class="image_container">'; echo "<a href='$image' rel='lightbox[roadtrip]'><img src= '$thumb' width='60' height='40' alt='$title'>"; echo '</a></div>'; } ?> </div> <!-- We will be working inside these tags --> </div> </div> </table></td> Hello all , I am facing a problem when trying to to show image files generated from php code in IE8 . it is working fine on firefox and IE9 . but in IE8 its showing the famous red X instead of the image ; belw is the code: Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html dir="RTL" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:v="urn:schemas-microsoft-com:vml" lang="en-us" > <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <head> <title>header </title> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body> <?php mb_internal_encoding('UTF-8'); /** * @author IT Department * @copyright 2011 */ INCLUDE ("header.php"); INCLUDE ("connect.php"); if (isset($_GET['id'])) { $ID=$_GET['id']; $sql="select employees.USER_ID, employees.NAME_ARAB, employees.NAME_ENG, employees.TITLE_ARAB, employees.TITLE_ENG, department.DEP_NAME_ENG, department.DEP_NAME_ARAB, location.LOC_DESC_ENG, location.LOC_DESC_ARAB, employees.MOBILE, employees.EMAIL, employees.DEP, employees.LOC FROM employees,location,department WHERE employees.DEP=department.DEP_ID AND employees.LOC=location.LOC_ID and employees.USER_ID=$ID "; //echo $sql; $result=mysql_query($sql,$link); mysql_query("SET NAMES 'utf8'"); ECHO '<html DIR="RTL">'; echo "<table width=100% border='1' cellpadding='8' align='center' bgcolor='white'>"; while ($row = mysql_fetch_array($result, MYSQL_NUM)) { //$row = mysql_fetch_assoc($result); echo"<tr align='center'>"; echo"<td>"; ECHO " الرقم الوظيفي :"; echo"</td>"; echo"<td colspan='2'>"; ECHO "<strong>$row[0]</strong>"; echo"</td>"; echo"<td>"; ECHO " : User ID "; echo"</td>"; echo"<td rowspan='7'>"; ECHO "<img src='IMAGE.php?id=".$row[0]."' width='225' height='300'/>"; //the image echo"</td>"; echo "</tr>"; the php image file is : Code: [Select] <?php INCLUDE ("connect.php"); $ID = "'".$_GET['id']."'"; $sql="SELECT PHOTO FROM employees WHERE USER_ID=$ID"; $result=mysql_query($sql,$link); $row = mysql_fetch_array($result); header("Content-type: image/pjpeg"); print ( $row[0]); ?> Thanks in advance for your help Here is the User profile search form... when i search that all details comes without Employee's Photo.. What's the error ? Code: [Select] </head> <body> <?php $uname = $_POST['uname']; $sql = "SELECT * FROM emp WHERE uname = '$uname'"; $result = mysql_query($sql); if (mysql_num_rows($result) > 0) { while ($row = mysql_fetch_array($result)) { $fname = $row['fname']; $lname = $row['lname']; $email = $row['email']; $address = $row['address_1']; $address2= $row['address_2']; $address3= $row['address_3']; $image = $row['image']; $gender=$row['gender']; $mobile=$row['tp_mobile']; $land=$row['tp_lnd']; $bod=$row['bod']; } } ?> <div class="main"> <div class="header"> <div class="header_resize"> <div class="logo"><h1></h1></div> <div class="clr"></div> <div class="search"> <form id="form1" name="form1" method="post" action="emp_profile.php"> <span> <input name="uname" type="text" class="keywords" id="textfield" maxlength="50" /> </span> <input name="image" type="image" src="images/search.gif" class="button" /> </form> </div> <div class="menu"> <ul> <!-- <li><a href="index.html" class="active">Home</a></li> <li><a href="services.html">Services</a></li> <li><a href="about.html"> About Us </a></li> <li><a href="contact.html"> Contact Us</a></li> --> </ul> </div> </div> <div class="clr"></div> </div> <div class="clr"></div> <div class="body"> <div class="body_resize"> <form id="" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" enctype="multipart/form-data" accept-charset='UTF-8'> <div id="container"> <fieldset > <div id="content-container1"> <div id="content-container2"> <div id="section-navigation"> <img align="top" width="175" height="200" src="emp_images/<?php echo $image; ?>"/> <div> <!-- <label>Patient Name : </label> --> <br /> </div> </div> <div id="content" align="justify"> <h2> <label for="fname"> <?php echo $fname; ?></label> <label for="lname"> <?php echo $lname; ?></label> </h2> <p> <label><b>Email:</b></label> <br /> <label for="email"> <?php echo $email; ?></label> </p> <p> <label><b>Employee Address:</b></label> <br /> <label > <?php echo $address; ?></label> </p> <p> <label><b>Employee Address 2:</b></label> <br /> <label > <?php echo $address2; ?></label> <p> <label><b>Employee Address 3:</b></label> <br /> <label > <?php echo $address3; ?></label> <p> <label><b>Gender:</b></label> <br /> <label > <?php echo $gender ?></label> </p> <p> <label><b>Employees Mobile:</b></label> <br /> <label > <?php echo $mobile ?></label> </p> <p> <label><b>Employees Resident Number:</b></label> <br /> <label > <?php echo $land ?></label> </p> <p> <label><b>Date of Birth:</b></label> <br /> <label > <?php echo $bod ?></label> </p> </div> </div> </fieldset> <div class="clr"></div> </div> </div> </form> <div class="footer"> <div class="footer_resize"> <p>© P2011-001</p> </div> <div class="clr"></div> </div> </div> </div> </div> </body> </html> <?php mysql_close($con); ?> So. I'm using this code right he <?php $imagepath = "css/images/statspage.jpg"; $image = imagecreatefromjpeg($imagepath); $imgheight = imagesy($image); $color = imagecolorallocate($image, 255, 255, 255); imagestring($image, 5, 70, $imgheight-50, "This is a test", $color); header('Content-Type: image/jpeg'); imagejpeg($image); ?> It works like it should. Now my problem is, is that the image is being displayed at a very low quality! Here's the original image: Here's the image with the code above: RIGHT away you can tell the HUGE difference. I'm not sure what I'm doing wrong. Maybe i need a higher res image? If y'all guys know a different method THAT also achieves the same thing I'm trying to do. Please let me know ASAP! Hi there i wanted to know how i could rule out certain rows from being shown in the pagination in this case i want to approve all information before it's posted i tried $sql = "SELECT * FROM tablename LIMIT $offset, $rowsperpage WHERE approved = 'Yes'"; But it didnt work Any help would be great, Thanks, Blink359 Hi Guys, New to php! I have a title attribute applied to a textarea but in the below code the title attribute just displays the first word of the associated sentence, if $translation is "The cat is on the mat" the title attribute on mouseover of the textarea only shows "The". Weird eh? Any ideas what the fix would be. Same in IE, Chrome and FF. How could I tweak this ".$translation." (highlighted in red in code below off to the right) in the context of the below code? It aint my code by the way By the way ".$translation." highlighted in green does show the full sentence eg "The cat is on the mat" I need the title attribute as a tooltip on a big matrix of textareas. Thanks Code: [Select] foreach ($translation_matrix[$this->ext->settings['base_language']] as $phrase_key => $translation) { $class = ($i % 2) ? "tableCellOne" : "tableCellTwo"; $r .= "<tr>"; $r .= "<td class='".$class." phrase-key'>".$phrase_key."</td>"; $r .= "<td class='".$class."'>[color=green]".$translation."[/color]</td>"; foreach ($matched_langs as $lang_key => $language) { $r .="<td class='".$class."'> ".$language."<textarea class='textarea' name='translations[".$lang_key."][".$phrase_key."]' title=[color=red]".$translation."[/color]>".((isset($translation_matrix[$lang_key][$phrase_key]) === TRUE) ? $translation_matrix[$lang_key][$phrase_key] : "")."</textarea></td>"; } $r .= "</tr>\n"; $i++; } $r .= "</tbody></table><input type='submit' value='".$LANG->line("submit")."' />"; $r .= "</form>"; $this->_render_layout('index', $r); } Hi all, Currently my dob_day is not showing any value, even though there is a value in the database, it seems like it is unable to retrieve the value. No value was shown in the <select> box. Do you guys have any idea? Thanks Code: [Select] <?php $query = "SELECT name, nric, gender, picture, dob_day FROM tutor_profile WHERE tutor_id = '" . $_GET['tutor_id'] . "'"; $data = mysqli_query($dbc, $query) or die(mysqli_error($dbc)); // The user row was found so display the user data if (mysqli_num_rows($data) == 1) { $row = mysqli_fetch_array($data); if ($row != NULL) { $name = $row['name']; $nric = $row['nric']; $gender = $row['gender']; $old_picture = $row['picture']; $dob_day = $row['dob_day']; } else { echo '<p class="error">There was a problem accessing your profile.</p>'; } //HTML CODING <label for="dob" class="label">Date Of Birth</label> <select id="dob_day" name="dob_day" value="<?php if (!empty($dob_day)) echo $dob_day; ?>"> <option> <option>01</option> <option>02</option> <option>03</option> <option>04</option> <option>05</option> <option>06</option> <option>07</option> <option>08</option> <option>09</option> <option>10</option> <option>11</option> <option>12</option> <option>13</option> <option>14</option> <option>15</option> <option>16</option> <option>17</option> <option>18</option> <option>19</option> <option>20</option> <option>21</option> <option>22</option> <option>23</option> <option>24</option> <option>25</option> <option>26</option> <option>27</option> <option>28</option> <option>29</option> <option>30</option> <option>31</option> </select> ?> What im trying to do is make a mysql result appear on my screen like this result 1 result 2 result 3 result 4 result 5 result 6 result 7 result 8 result 9 i will be using the query like mysql_query("SELECT * FROM `cars` ORDER BY `id`"); so how will i get it to display like that thanks I need help with this script...... i get the error... 'Undefined index: username in C:\wampnew\www\login and register\profile.php on line 28!' <?php require("include/connect.php"); if(!isset($_GET['id'])) { echo("Please enter a members profile to view."); die(); } elseif($_GET['id'] == "") { echo("Please enter a members profile to view."); die(); } $pid = mysql_real_escape_string(preg_replace("@[^a-z0-9]@i","",$_GET['id'])); $check = mysql_num_rows(mysql_query("SELECT id FROM tut_users WHERE id='{$pid}'")); if($check !="1") { echo("Member does not exist."); require("footer.php"); die(); } $sql = mysql_query("SELECT * FROM tut_users WHERE id='{$pid}'") or die(mysql_error()); $fetch = mysql_fetch_assoc($sql) or die(mysql_error()); $username = mysql_real_escape_string(preg_replace("@[^a-z0-9]@i","",$fetch['username'])); echo("Member Profile Of: {$username} <br /> " ); ?> Could someone please help me thanks... Hi everyone, i have currently have a registration and login page working, i have now included a profile/edit profile page once the user is logged in. However im having a problem, once the user logs in the account page welcomes them by there username using the following code <h2>Welcome, <?php echo $_SESSION['username']; ?></h2> Which is fine, however when users edit there profile there details arent stored into there userid within the mysql database. for example this is my edit profile page and this is what it does within the mysql database: It doesn't save that info to the current user and im not sure how to get it to do it, heres my code: <?PHP //Database Information $dbhost = "localhost"; $dbname = "blank"; $dbuser = "blank"; $dbpass = "password"; //Connect to database mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error()); mysql_select_db($dbname) or die(mysql_error()); $real_name = $_POST['real_name']; $location = $_POST['location']; $mobile_number = $_POST['mobile_number']; $instant_messaging = $_POST['instant_messaging']; $query = "REPLACE INTO users (real_name, location, mobile_number, instant_messaging) VALUES('$real_name', '$location', '$mobile_number', '$instant_messaging')"; mysql_query($query) or die(mysql_error()); mysql_close(); ?> I can see why it doesn't work as it just inserts it into the users database but I'm not sure how to associate it with the current logged in user. Any help would be great, Lee I need a little help here. I have a function currently that allows me to send data to a php script from my C++ application. How can I do the opposite? C++ Code below to send data to the php script: Code: [Select] void SendData() { char* Navigate = new char[500]; memset(( void* )Navigate, 0, 500); char* Version = "Version 1.0"; sprintf(Navigate, "MYSITE.COM/GetData.php?v=%s", Version); SendFunction(Navigate); } DWORD SendFunction(char* link) { char* szURL = link; HINTERNET hSession; HINTERNET hRequest; hSession = InternetOpen( // Make internet connection. "Microsoft Internet Explorer", // agent INTERNET_OPEN_TYPE_PRECONFIG, // access NULL, NULL, 0); // defaults if(hSession) { hRequest = InternetOpenUrl( // Make connection to desired page. hSession, // session handle link, // URL to access NULL, 0, 0, 0); // defaults } if(hRequest) { bool bResult = HttpSendRequest(hRequest, NULL, 0, NULL, 0); } InternetCloseHandle(hSession); return 0; } php script that receives the data from the C++ application: <? $f=fopen('FILE','a'); fwrite($f,$_GET['v'] \n); fclose($f); ?> This just simply sends the char* Version = "Version 1.0" text to the php script witch _GETs it and writes it to a file. Simple and impractical, however I just wanted to get something rolling. It works fine, now I need to do the opposite. I need to do exactly what this function does, but flip it around!. I want store a value in the php script, and get that value with my C++ application, and then log it out. Any help here please!? php script for what I want to do: <?php $dbhost = 'MyHost'; $dbuser = 'MyUserName'; $dbpass = 'MyPassword'; mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); $dbname = 'MyDB'; mysql_select_db($dbname); $query = mysql_query("SELECT * FROM AppVersion"); while($row = mysql_fetch_array($query)) { $version = $row['Version Info']; } ?> I need to query the php script from my C++ application and retrieve the value of $version. How can I setup the php script to export that value $version for the C++ app and use the WinInet funcs to retrieve it? Note: I am just trying to get a feel for how all of this works right now, so none of this really has a practical use at the moment, but is helping me progress in my overall goal, so it will be very helpful to get this worked out. Hello, is it possible to define the next page after a form submission based on a value from the form ? Example: My form has a dropdown Value 1: Flight Value 2: Flight + Hotel now i'm trying to achieve that if value 1 is chosen after submission it goes to flight.php, if value 2 it should go to flighthotel.php or am i heading into the completely wrong direction here and over complicating things ? Thanks in advance ! Hi all, I'm developing a website and i need to upload a xml spreadsheet and see data at screen just to verify if it is correct. So far so good. But after the user see the data in the screen, he should be able to import that file to mssql. The problem is, in this second page where i show the data that the XML spreadsheet contains, i don't have the file location to submit the file again. How can i resolve this problem? Any ideas? Thanks in advance. Regards Hello, We've been working on a page that allows users to create their own avatar to be displayed on their page. We can get the script working but the only way to show the image is to save it to a temp folder, we want to just save the string in the database and let the php show this wehen required here are the file http://test.digitaldemocracy.org.uk/test_avatar.php <!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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="author" content="John Munro, Democratise Ltd" /> <meta name="copyright" content="Democratise Ltd 2010" /> <meta name="description" content="Digital Democracy -" /> <meta name="keywords" content=" add here" /> <meta name="robots" content="index, follow" /> <meta name="revisit-after" content="1 week" /> <meta http-equiv="Page-Exit" content="blendTrans(Duration=0.5)" /> <link rel="SHORTCUT ICON" href="http://www.digitaldemocracy.co.uk/favicon.ico" /> <title>Digital Democracy -</title> <link href="css/site.css" rel="stylesheet" type="text/css" /> <link href="css/basic.css" rel="stylesheet" type="text/css" /> <link rel="stylesheet" href="avatars/avatar.css" type="text/css" /> <script type="text/javascript" src="avatars/avatar.js"></script> <style type="text/css"> /*<![CDATA[*/ <!-- body { background-image: url(images/background_paper.jpg); background-repeat: repeat; } --> /*]]>*/ </style> <script type="text/javascript"> //<![CDATA[ var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-15681567-1']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); //]]> </script> </head> <body> <div id="wrapper"> <div id="inner_wrapper"> <div class="header"> <div class="header_logo"> <img src="images/header_logo.png" width="190" height="55" alt="Digital Democracy" /> </div> <div class="header_link"> Make a<br/>proposal </div> <div class="header_link_spacer"> <img src="images/header_link_spacer.png" width="5" height="55" alt="Digital Democracy - Link Spacer image" /> </div> <div class="header_link"> View<br/>proposal </div> <div class="header_link_spacer"> <img src="images/header_link_spacer.png" width="5" height="55" alt="Digital Democracy - Link Spacer image" /> </div> <div class="header_link"> Vote on top<br/>proposal </div> <div class="header_link_spacer"> <img src="images/header_link_spacer.png" width="5" height="55" alt="Digital Democracy - Link Spacer image" /> </div> <div class="header_link"> View<br/>results </div> <div class="header_link_spacer"> <img src="images/header_link_spacer.png" width="5" height="55" alt="Digital Democracy - Link Spacer image" /> </div> <div class="header_link_single_line"> Profile </div> <div class="header_link_spacer"> <img src="images/header_link_spacer.png" width="5" height="55" alt="Digital Democracy - Link Spacer image" /> </div> <div class="header_link_single_line"> More </div> <div id="header_search_bar"> <form action="Search" method="post"> <input name="Search" type="text" value="Search" size="15" /> <input name="Submit" type="button" value="Go" /> </form> </div> <div class="header_login"> <span class="header_login_text">Login / Register</span> </div> </div> <div id="info"> <div id="chosen_avatar"> <!--<p> avatar to be shown here when completed only - image shown below is thee to reference the saved code</p>--> <p><img src="<?php if (!empty($image)) { echo $filename; } else { echo 'http://test.digitaldemocracy.org.uk/avatar_creator.php?avatar[background]=bg_08&avatar[body]=body_01&avatar[head]=head_01&avatar[eyes]=blank&avatar[mouth]=blank&avatar[moustache]=blank&avatar[glasses]=blank&avatar[male_hair]=blank&avatar[female_hair]=blank';} ?>" title="Your chosen avatar (assembled as a PNG image)" alt="Your chosen avatar (PNG image)" /></p> <p>Your chosen avatar</p> </div> <form action="http://test.digitaldemocracy.org.uk/avatar_creator.php" method="get"> <div id="avatar_section"> <div id="avatar_stack"> <p> <img src="avatars/bg_01.png" alt="" /><input name="avatar[background]" type="radio" value="bg_01" checked="checked" /> <img src="avatars/bg_02.png" alt="" /><input name="avatar[background]" type="radio" value="bg_02" /> <img src="avatars/bg_03.png" alt="" /><input name="avatar[background]" type="radio" value="bg_03" /> <img src="avatars/bg_04.png" alt="" /><input name="avatar[background]" type="radio" value="bg_04" /> <img src="avatars/bg_05.png" alt="" /><input name="avatar[background]" type="radio" value="bg_05" /> <img src="avatars/bg_06.png" alt="" /><input name="avatar[background]" type="radio" value="bg_06" /> <img src="avatars/bg_07.png" alt="" /><input name="avatar[background]" type="radio" value="bg_07" /> <img src="avatars/bg_08.png" alt="" /><input name="avatar[background]" type="radio" value="bg_08" /> <img src="avatars/bg_09.png" alt="" /><input name="avatar[background]" type="radio" value="bg_09" /> </p> <p> <img src="avatars/body_01.png" alt="" /><input name="avatar[body]" type="radio" value="body_01" checked="checked" /> <img src="avatars/body_02.png" alt="" /><input name="avatar[body]" type="radio" value="body_02" /> <img src="avatars/body_03.png" alt="" /><input name="avatar[body]" type="radio" value="body_03" /> <img src="avatars/body_04.png" alt="" /><input name="avatar[body]" type="radio" value="body_04" /> <img src="avatars/body_05.png" alt="" /><input name="avatar[body]" type="radio" value="body_05" /> <img src="avatars/body_06.png" alt="" /><input name="avatar[body]" type="radio" value="body_06" /> <img src="avatars/body_07.png" alt="" /><input name="avatar[body]" type="radio" value="body_07" /> <img src="avatars/body_08.png" alt="" /><input name="avatar[body]" type="radio" value="body_08" /> </p> <p> <img src="avatars/head_01.png" alt="" /><input name="avatar[head]" type="radio" value="head_01" checked="checked" /> <img src="avatars/head_02.png" alt="" /><input name="avatar[head]" type="radio" value="head_02" /> <img src="avatars/head_03.png" alt="" /><input name="avatar[head]" type="radio" value="head_03" /> <img src="avatars/head_04.png" alt="" /><input name="avatar[head]" type="radio" value="head_04" /> <img src="avatars/head_05.png" alt="" /><input name="avatar[head]" type="radio" value="head_05" /> <img src="avatars/head_06.png" alt="" /><input name="avatar[head]" type="radio" value="head_06" /> <img src="avatars/head_07.png" alt="" /><input name="avatar[head]" type="radio" value="head_07" /> <img src="avatars/head_08.png" alt="" /><input name="avatar[head]" type="radio" value="head_08" /> </p> <p> <img src="avatars/blank.png" alt="" /><input name="avatar[eyes]" type="radio" value="blank" checked="checked" /> <img src="avatars/eyes_1.png" alt="" /><input name="avatar[eyes]" type="radio" value="eyes_1" /> <img src="avatars/eyes_2.png" alt="" /><input name="avatar[eyes]" type="radio" value="eyes_2" /> <img src="avatars/eyes_3.png" alt="" /><input name="avatar[eyes]" type="radio" value="eyes_3" /> <img src="avatars/eyes_4.png" alt="" /><input name="avatar[eyes]" type="radio" value="eyes_4" /> <img src="avatars/eyes_5.png" alt="" /><input name="avatar[eyes]" type="radio" value="eyes_5" /> <img src="avatars/eyes_6.png" alt="" /><input name="avatar[eyes]" type="radio" value="eyes_6" /> </p> <p> <img src="avatars/blank.png" alt="" /><input name="avatar[mouth]" type="radio" value="blank" checked="checked" /> <img src="avatars/mouth_1.png" alt="" /><input name="avatar[mouth]" type="radio" value="mouth_1" /> <img src="avatars/mouth_2.png" alt="" /><input name="avatar[mouth]" type="radio" value="mouth_2" /> <img src="avatars/mouth_3.png" alt="" /><input name="avatar[mouth]" type="radio" value="mouth_3" /> <img src="avatars/mouth_4.png" alt="" /><input name="avatar[mouth]" type="radio" value="mouth_4" /> <img src="avatars/mouth_5.png" alt="" /><input name="avatar[mouth]" type="radio" value="mouth_5" /> <img src="avatars/mouth_6.png" alt="" /><input name="avatar[mouth]" type="radio" value="mouth_6" /> </p> <p> <img src="avatars/blank.png" alt="" /><input name="avatar[moustache]" type="radio" value="blank" checked="checked" /> <img src="avatars/moustache_01.png" alt="" /><input name="avatar[moustache]" type="radio" value="moustache_01" /> <img src="avatars/moustache_02.png" alt="" /><input name="avatar[moustache]" type="radio" value="moustache_02" /> <img src="avatars/moustache_03.png" alt="" /><input name="avatar[moustache]" type="radio" value="moustache_03" /> <img src="avatars/moustache_04.png" alt="" /><input name="avatar[moustache]" type="radio" value="moustache_04" /> </p> <p> <img src="avatars/blank.png" alt="" /><input name="avatar[glasses]" type="radio" value="blank" checked="checked" /> <img src="avatars/glasses_01.png" alt="" /><input name="avatar[glasses]" type="radio" value="glasses_01" /> <img src="avatars/glasses_02.png" alt="" /><input name="avatar[glasses]" type="radio" value="glasses_02" /> <img src="avatars/glasses_03.png" alt="" /><input name="avatar[glasses]" type="radio" value="glasses_03" /> <img src="avatars/glasses_04.png" alt="" /><input name="avatar[glasses]" type="radio" value="glasses_04" /> <img src="avatars/glasses_05.png" alt="" /><input name="avatar[glasses]" type="radio" value="glasses_05" /> <img src="avatars/glasses_06.png" alt="" /><input name="avatar[glasses]" type="radio" value="glasses_06" /> <img src="avatars/glasses_07.png" alt="" /><input name="avatar[glasses]" type="radio" value="glasses_07" /> </p> <p> <img src="avatars/blank.png" alt="" /><input name="avatar[hair 1]" type="radio" value="blank" checked="checked" /> <img src="avatars/m_hair_01.png" alt="" /><input name="avatar[hair 1]" type="radio" value="m_hair_01" /> <img src="avatars/m_hair_02.png" alt="" /><input name="avatar[hair 1]" type="radio" value="m_hair_02" /> <img src="avatars/m_hair_03.png" alt="" /><input name="avatar[hair 1]" type="radio" value="m_hair_03" /> <img src="avatars/m_hair_04.png" alt="" /><input name="avatar[hair 1]" type="radio" value="m_hair_04" /> <img src="avatars/m_hair_05.png" alt="" /><input name="avatar[hair 1]" type="radio" value="m_hair_05" /> <img src="avatars/m_hair_06.png" alt="" /><input name="avatar[hair 1]" type="radio" value="m_hair_06" /> <img src="avatars/m_hair_07.png" alt="" /><input name="avatar[hair 1]" type="radio" value="m_hair_07" /> <img src="avatars/m_hair_08.png" alt="" /><input name="avatar[hair 1]" type="radio" value="m_hair_08" /> </p> <p> <img src="avatars/blank.png" alt="" /><input name="avatar[hair 2]" type="radio" value="blank" checked="checked" /> <img src="avatars/f_hair_01.png" alt="" /><input name="avatar[hair 2]" type="radio" value="f_hair_01" /> <img src="avatars/f_hair_02.png" alt="" /><input name="avatar[hair 2]" type="radio" value="f_hair_02" /> <img src="avatars/f_hair_03.png" alt="" /><input name="avatar[hair 2]" type="radio" value="f_hair_03" /> <img src="avatars/f_hair_04.png" alt="" /><input name="avatar[hair 2]" type="radio" value="f_hair_04" /> <img src="avatars/f_hair_05.png" alt="" /><input name="avatar[hair 2]" type="radio" value="f_hair_05" /> <img src="avatars/f_hair_06.png" alt="" /><input name="avatar[hair 2]" type="radio" value="f_hair_06" /> <img src="avatars/f_hair_07.png" alt="" /><input name="avatar[hair 2]" type="radio" value="f_hair_07" /> <img src="avatars/f_hair_08.png" alt="" /><input name="avatar[hair 2]" type="radio" value="f_hair_08" /> </p> </div> </div> <p> </p> <p id="submit" > <input type="submit" value="Click here to save your personalised Avatar" /> </p> </form> <div id="hidden_spacer"> <p> </p> </div> </div> </div> </div> <div class="footer"> <div class="footer_content"> <div id="footer_democratise"> © Democratise Ltd </div> <div class="footer_link_single_line"> About us </div> <div class="footer_link_spacer"> <img src="images/header_link_spacer.png" width="5" height="55" alt="Digital Democracy - Link Spacer image" /> </div> <div class="footer_link_single_line"> Contact </div> <div class="footer_link_spacer"> <img src="images/header_link_spacer.png" width="5" height="55" alt="Digital Democracy - Link Spacer image" /> </div> <div class="footer_link_single_line"> Blog </div> <div class="footer_link_spacer"> <img src="images/header_link_spacer.png" width="5" height="55" alt="Digital Democracy - Link Spacer image" /> </div> <div class="footer_link_single_line"> Help </div> <div class="footer_link_spacer"> <img src="images/header_link_spacer.png" width="5" height="55" alt="Digital Democracy - Link Spacer image" /> </div> <div class="footer_link_single_line"> </div> <div class="footer_link_spacer"> <img src="images/header_link_spacer.png" width="5" height="55" alt="Digital Democracy - Link Spacer image" /> </div> <div class="footer_link_single_line"> </div> <div class="footer_link_spacer"> <img src="images/header_link_spacer.png" width="5" height="55" alt="Digital Democracy - Link Spacer image" /> </div> <div class="footer_link_single_line"> Privacy </div> </div> </div> </body> </html> And the file that runs the php and creates the images is <?php # form inputs in the correct stacking order from bottom to top $form_fields = array('background', 'body', 'head', 'eyes', 'mouth', 'moustache', 'glasses', 'hair 1', 'hair 2'); ob_start(); if(!isset($_GET['avatar'])) die; validate_inputs($form_fields); $filename = create_avatar($form_fields); //ob_end_clean(); //echo "hello"; //$image = output_image(ob_get_clean()); $image_output = ob_get_contents(); //ob_end_clean(); //echo $image; //$image = ob_get_contents(); //$image="data:image/png;base64, base64_encode($image)"; $image = 'test.digitaldemocracy.org.uk' . $_SERVER['REQUEST_URI']; //$image = $_SERVER['REQUEST_URI']; //echo $image; function validate_inputs($inputs) { foreach($inputs as $item) { if((preg_match('@(\.|/)@', $_GET['avatar'][$item])) or (!is_file('avatars/'.$_GET['avatar'][$item].'.png'))) { die(); } } } function create_avatar($inputs) { while($inputs) { $layer = @imagecreatefrompng('avatars/'. ($file = $_GET['avatar'][array_shift($inputs)]). '.png') or die('I could not open the avatars/'.$file); $layerWidth = imageSX($layer); $layerHeight = imageSY($layer); if(!isset($slate)) { $slate = @imagecreatetruecolor($layerWidth, $layerHeight); } @imagecopy($slate, $layer, 0, 0, 0, 0, $layerWidth, $layerHeight); @imagedestroy($layer); } imagetruecolortopalette ($slate, false, 256); //header('Content-Type: image/png'); $filename = 'temp'. rand(1,50) . '.png'; imagepng($slate, $filename); //imagepng($slate); imagedestroy($slate); return $filename; } function output_image($image) { $hash = md5($image); if(isset($_SERVER['HTTP_IF_NONE_MATCH'])){ if($hash == trim($_SERVER['HTTP_IF_NONE_MATCH'], '"')){ header("HTTP/1.x 304 Not Modified"); header('Etag: "'.$hash.'"'); die(); } } //header('Etag: "'.$hash.'"'); //header('Content-Type: image/png'); //imagepng($image); //echo $image; //return $image; } //header ("Location:test_avatar.php?image=$image"); include 'test_avatar.php'; ?> If anybody can help us it would be very appreciated Thanks John Munro Democratise.org Hi all, Please I need an urgent help, I'm working on a project : www.playnetwork.com/record I want it such that when you click on the the artist link (menu) it will pull out the artists' records such as Name, Albums, Height etc. from a database Please help me out I'm kind off rookie to php Thanks Hello, first of all i'm new here and i kinda like the community... so here i go with my question... When i register and then click on the link to get me to the log in file i have set the link for my member profile to be member.php?p=$_SESSION['id'] .. which works until now.. and lets say for instance my ID is 25... when i type on the browser member.php?p=553524 i will still be on the same page... so what i want to do is to check which id is typed and then throw them to the correct account profile or if the ID does not exist then throw them to a member-not-exist.php file.. I think i can do the how to check the id if it does exist but for the other one? Thanks in advance. Hi. I am working on a website that has restriction level. An admin, a staff, and ordinary user. In my admin page when I click the button "View Users" it shows all the listed users in a table, from admin to ordinary users. And on each entry is an option to either "Delete" or "Edit" the users account. Now I have a problem with editing user profile because it appears blank fields. Not like in the admin side wherein if I click "Edit" the fields are filled with the users info. How do I do this in the staff's page. Here is the view users code from the admin's page: Code: [Select] if (@$_GET['action'] == "View Users") { print "<font size=6 color=yellow><center>View User's Records</center><br></font>"; $result = mysql_query ("SELECT * FROM users order by user_lvl, lname asc"); $rows = mysql_num_rows($result); if ($rows!=0) { print "<table border=1 align=center cellspacing=10>"; print " <tr bgcolor=yellow align=center> <td>First Name</td> <td>Last Name</td> <td>Email</td> <td>Username</td> <td>Password</td> <td>Phone Number</td> <td>User Privilege</td> <td>Options</td> </tr>"; for ($i=0; $i< $rows; $i++) { $row = mysql_fetch_row ($result); print "<tr bgcolor= white align=center>"; print "<td>$row[0]</td>"; print "<td>$row[1]</td>"; print "<td>$row[2]</td>"; print "<td>$row[3]</td>"; print "<td>$row[4]</td>"; print "<td>$row[5]</td>"; print "<td>$row[6]</td>"; print "<td>[ <a href=admin_main.php?action=Delete&username=$row[3]>Delete</a> ]"; print "[ <a href=admin_main.php?action=Edit&username=$row[3]>Edit</a> ]"; print "</td>"; print "</tr>"; } print "</table>"; print "<font size=1 color=yellow>Number of entries found: $rows"; } else { print "No records found!"; } mysql_free_result ($result); } Now here is the code when I click "Edit" from the "View Users" table: Code: [Select] if (@$_GET['action'] == "Edit") { $result = mysql_query ("Select * from users where username='$_GET[username]'"); $row = mysql_fetch_row ($result); print "<font size=6 color=yellow><center>Edit Records </center></font>"; print "<form method = get> <table border = 1 align=center> <tr> <td><font color=yellow>First Name:</font></td> <td><input type=text name=fname value=$row[0] ></td></tr> <tr> <td><font color=yellow>Last Name:</font></td> <td><input type=text name=lname value=$row[1]></td></tr> <tr> <td><font color=yellow>Email Address: </font></td> <td><input type=text name=email value=$row[2] </td></tr> <tr> <td><font color=yellow>Username: </font></td> <td><input type = text name = username value=$row[3] ></td></tr> <tr> <td><font color=yellow>Password:</font></td> <td><input type=text name=password value=$row[4]></td></tr> <tr> <td><font color=yellow>Contact Number:</font></td> <td><input type = text name = phone_number value=$row[5]></td></tr> <tr> <td><font color=yellow>User Privilege:</font></td> <td><input type = txt name = user_lvl value=$row[6]></td></tr> <tr><td><input type=submit value='Update Users' Submit name=action></td></tr> </table> </form> "; } if (@$_GET['action']=="Update Users") { $result = mysql_query ("UPDATE users SET fname='$_GET[fname]', lname='$_GET[lname]', email='$_GET[email]', username='$_GET[username]', password='$_GET[password]', phone_number='$_GET[phone_number]', user_lvl='$_GET[user_lvl]' where username= '$_GET[username]'"); print "<font size=6 color=yellow><center><blink>Record of User successfully updated!</blink></center></font>"; } |