Jump to content

karthikjayraj

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

karthikjayraj's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I have been trying to replicate the facebook "share" functionality , well actually i was in need of this functionality even before i knew that fb already had it.. I learnt a few things that this can be achieved by using the "Curl" and I also hear that this setting may have been switched in some servers so if anyone can refer me to other options that would always fetch me the - Title- Description- Images for sure I' d be thankful Regards
  2. Hi , i am working on a PHP code that would fetch me the" title and the description" from another web page something similar to www.Digg.com .After searching a couple of Open source codes developed by some generous coder I found this piece of code: I have tested this code and it works fine, but the confusion here is it only works from external internet and Iam not able to extract the contents when i use the same piece of code from my office intranet(Our intranet has full access to the internet ) and the best part is when i use the same url for fetching content from Digg.com from my office intranet it works fine. The error I get is file_get_contents time out after 60 seconds OR I get a blank page result without any content But the same piece of code when used outside of my intranet works perfectly fine. Please let me know if you find anything incorrect! Thanks <?php if(isset($_POST['submitlink'])) { function getMetaTitle($content){ $pattern = "|<[\s]*title[\s]*>([^<]+)<[\s]*/[\s]*title[\s]*>|Ui"; if(preg_match($pattern, $content, $match)) return $match[1]; else return false; } $url = $_POST['submitlink']; $data = array(); // get url title $content = @file_get_contents($url); $data['title'] = getMetaTitle($content); // get url description from meta tag $tags = @get_meta_tags($url); $data['description'] = $tags['description']; $dom = new domDocument; @$dom->loadHTML($content); $dom->preserveWhiteSpace = false; $images = $dom->getElementsByTagName('img'); foreach($images as $img) { $imgurl = $img->getAttribute('src'); $alt = $img->getAttribute('alt'); //$size = getimagesize($imgurl); //echo "Title: $alt<br>"; //echo $imgurl; //echo '<img src="'.$imgurl.'" title="'.$alt.'" width="50px"/>'; } $formdata .= '<table><tr><td>Title:</td><td><a href='; $formdata .= 'gethome.php?url='; $formdata .= $url; $formdata .= '>'; $formdata .= json_encode($data['title']); $formdata .= '</a></td></tr>'; $formdata .= '<tr><td>Description:</td><td> '; $formdata .= json_encode($data['description']); $formdata .= '</td></tr></table>'; }
  3. Thanks nothing worked....I had to drop the option of going BACK :'(
  4. Hi, I have set up 2 php pages page 1 - add_entry2.php In this page I have a invoice table created where I can dynamically add/delete rows. This has a View Bill button which takes me to page 2- add_entry3.php In this page it shows up the rows added in page 1 in read only format, so if the user wants to modify the data that he/she entered then he must Click on <back> that i have provided in the page 2 which will direct him to page 1 Now the problem starts here on click of Back the dynamically added rows dissappear..which is frustrating..I know its something to do with my code..but can anyone help me fix it. One more thing is that i dont want to store the data into DB till the finalise button is clicked on page 2 so that means till page 2 is submitted nothing goes to DB from Page 1. I am able to retain values if I use the code <form action="add_entry2.php" name="eval_edit" method="post" format="html"> i,e if I submit back to the same page and retrieve values form $_POST but If I use the code <input type="button" value="Back" onClick="history.go(-1);return true;"> to get back to add_entry2.ph it looses all the values. Is there any other way to code the BACK link retaining my $_POST values(Do you think $_SESSION would work in this case?)
  5. I am able to retain values if I use i,e if I submit back to the same page and retrieve values form $_POST <form action="add_entry2.php" name="eval_edit" method="post" format="html"> but If I use the code below to get back to add_entry2.ph it looses all the values. Is there any other way to code the back page retaining my $_POST values <input type="button" value="Back" onClick="history.go(-1);return true;">
  6. Hi, I have set up 2 php pages page 1 - add_entry2.php In this page I have a invoice table created where I can dynamically add/delete rows. This has a View Bill button which takes me to page 2- add_entry3.php In this page it shows up the rows added in page 1 in read only format, so if the user wants to modify the data that he/she entered then he must Click on <back> that i have provided in the page 2 which will direct him to page 1 Now the problem starts here on click of Back the dynamically added rows dissappear..which is frustrating..I know its something to do with my code..but can anyone help me fix it. One more thing is that i dont want to store the data into DB till the finalise button is clicked on page 2 so that means till page 2 is submitted nothing goes to DB from Page 1. here is the code(I have removed the java script functionalities to reduce length of the post) add_entry2.php <html> <head> <title>Page Title</title> </head> <body leftmargin="0" topmargin="0"> <!--- forms are good when you wanna actually do stuff ---> <form action="add_entry3.php" name="eval_edit" method="post" format="html"> <table align="center" width = "75%"> <tr> <td align = "center"> Invoice </td> </tr> <tr> <td align = "center"> <!--- very imporant to give the table an id ---> <!--- otherwise it won't know where to edit ---> <table border="1" id="mySampleTable"> <tr> <th>Item No</th> <th>Item Name</th> <th>Item code</th> <th>Description</th> <th>Unit Cost</th> <th>Quantity</th> <th>Price</th> <th>Cancel ?</th> </tr> <tr> <td>1</td> <td><input type="text" name="itemname[]" size="40" maxsize="100"/></td> <td><input type="text" name="itemcode[]" size="20" maxsize="100" /></td> <td><input type="text" name="description[]" size="20" maxsize="100" /></td> <td><input type="text" name="unitcost[]" size="10" maxsize="100" /></td> <td><input type="text" name="quantity[]" size="4" maxsize="100" /></td> <td><input type="text" name="price[]" size="10" maxsize="100" /></td> <td><input type="CHECKBOX" name="cancel[]"/></td> </tr> </table> <table id="totaltbl"> <tr> <th>Total</th> <th>Vat%</th> </tr> <tr> <td><input type="text" name="total" size="20" maxsize="100" /></td> <td><input type="text" name="total" size="3" maxsize="3" /></td> </tr> </table> <!--- our buttons call our javascript functions when clicked ---> <p> <input type="button" value="Add Row" onclick="addRow();" /> <input type="button" value="Calculate Total Amount" onclick="Totalcal();" /> <input type="hidden" name="count" value=""/> <!--<input type="submit" name="submit" onclick="countRow();" value="Insert into Invoice!" />--> <input type="submit" name="submit" value="View Bill" /> <input type="hidden" name="submitted" value="true" /> </p> </td> </tr> </table> </form> </body> </html> ****************************************************8888 This is add_entry3.php <?php $num=count($_POST['itemcode']); $itemname= $_POST['itemname']; $itemcode = $_POST['itemcode']; $unitcost = $_POST['unitcost']; $description = $_POST['description']; $unitcost = $_POST['unitcost']; $quantity = $_POST['quantity']; $price = $_POST['price']; $problem = FALSE; ?> <h1 align ="center"><b><u>Invoice Details</b></u></h1> <table align="center" width = "75%"> <tr> <td align = "center"> <table border="1" id="mySampleTableheader"> <tr> <td width="75"><b>Item No</b></td> <td width="275"><b>Item Name</b></td> <td width="155"><b>Item code</b></td> <td width="155"><b>Description</b></td> <td width="95"><b>Unit Cost</b></td> <td width="60"><b>Quantity</b></td> <td width="95"><b>Price</b></td> </tr> </table> <?php $i=0; while ($i < $num) { ?> <!--- forms are good when you wanna actually do stuff ---> <form action="save_entry.php" name="eval_edit" method="post" format="html"> <table border="1" id="mySampleTable"> <tr> <td width="75"><?php echo $i+1; ?></td> <td><input type="text" name="itemname[]" value = "" size="40" maxsize="100" readonly/></td> <td><input type="text" name="itemcode[]" value ="<?php echo $itemcode[$i]; ?>" size="20" maxsize="100" readonly/></td> <td><input type="text" name="description[]" value ="<?php echo $description[$i]; ?>" size="20" maxsize="100" readonly/></td> <td><input type="text" name="unitcost[]" value ="<?php echo $unitcost[$i]; ?>" size="10" maxsize="100" readonly/></td> <td><input type="text" name="quantity[]" value = "<?php echo $quantity[$i]; ?>" size="4" maxsize="100" readonly/></td> <td><input type="text" name="price[]" value = "<?php echo $price[$i]; ?>" size="10" maxsize="100" readonly/></td> </tr> </table> <?php $i++;} ?> <!--- our buttons call our javascript functions when clicked ---> </td> </tr> </table> <p> <table id="totaltbl"> <tr> <th>Total</th> </tr> <tr> <td><input type="text" name="total" size="20" maxsize="100" /></td> </tr> </table> <input type="button" value="Add Row" onclick="addRow();" /> <input type="button" value="Row count" onclick="countRow();" /> <input type="hidden" name="count" value=""/> <!--<input type="hidden" name="count" value=""/> <input type="submit" name="submit" onclick="countRow();" value="Insert into Invoice!" />--> <input type="button" value="Back" onClick="history.go(-1);return true;"> <input type="submit" name="submit" value="Finalise" /> <input type="hidden" name="submitted" value="true" /> </p> </form> </body> </html>
  7. Thanks for your instant replies Pikachu.. I changed the code to look like this below and it worked!!!! <?php if (isset($_POST['submit'])) { if(!$_POST['uname'] | !$_POST['passwd']) {print'You did not fill in a required field.'; } header('Location: add_entry2.php'); }else{ echo "<form action=\"login1.php\" method=\"POST\">"; echo "Username: <input name=\"uname\" size=\"15\"><br />"; echo "Password: <input type=\"password\" name=\"passwd\" size=\"8\"><br />"; echo "<input type=\"submit\" name=\"submit\" value=\"Login\">"; echo "</form>";} ?>
  8. Yes I did and have checked for 1.whitespaces/unwanted lines but dint get through 2. My form will not post anything on the output after it has been submitted for the first time..what i mean is i am not posting anything before the Header() function. OR if you think there is some other command where i can direct my page based on success of some if condition NOT click then please do let me know. Thanks in advance.
  9. Hi, I found a code for login page on web which would check against the database and login, I wanted to modify it so that once the password is verified the user will be directed to a new page with the session variables also active. I read about " header()" functionality which would achieve this so i added this to the code but my code seems to fail with the error "Cannot modify header information - headers already sent by (output started at C:\xampp\phpMyAdmin\scripts\login1.php:7) in C:\xampp\phpMyAdmin\scripts\login1.php on line 10 " The code for login1.php is as below- For quick understanding i have removed all the section related to DB validation ..so the below code must activate the next page "add_entry2.php" immediately after submit button is pressed. Please see below.. Thanks in advance. <html> <head> <title>Login</title> </head> <body> <?php if (isset($_POST['submit'])) {if(!$_POST['uname'] | !$_POST['passwd']){die('You did not fill in a required field.'); } header('Location: add_entry2.php');} else {// if form hasn't been submitted ?> <h1>Login</h1> <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post"> <table align="center" border="1" cellspacing="0" cellpadding="3"> <tr><td>Username:</td><td> <input type="text" name="uname" maxlength="40"> </td></tr> <tr><td>Password:</td><td> <input type="password" name="passwd" maxlength="50"> </td></tr> <tr><td colspan="2" align="right"> <input type="submit" name="submit" value="Login"> </td></tr> </table> </form> <?php } ?> </body> </html>
  10. Hi, I am fairly new to PHP and I have built a page which accepts values from dynamically added rows so there is a combination of HTML,Javascript and PHP in the process. I am caught up with a problem HTML section In my form I have a table with a column as below and a dynamic "Add Row" which would increment the row in javascript and assign a new value to the input name as txtRow2,txtRow3,txtRow4 and so on based on the number of iteration " <tr><td><input type="text" name="txtRow1" id="txtRow1" size="40" /></td></tr> <input type="button" value="Add Row" onclick="addRow();" />" Javascript section The below code generates the new row in js var cellRight2 = row.insertCell(1); var e1 = document.createElement('input'); e1.type = 'text'; e1.name = 'txtRow1' + iteration; e1.id = 'txtRow1' + iteration; e1.size = 20; cellRight1.appendChild(e1); I hope you have understood what I have done till above.. Now comes the problematic part PHP section( I love PHP ) I have to insert the column values into mysql and i will do this using a for loop within which I will have my insert statement INSERT INTO test values($txtRow) Lets say I added 4 rows dynamically with values held in $txtRow1,$txtRow2,$txtRow3,$txtRow4(See the java script section) how would I use these values in my PHP insert statement as I don't want to write 4 different insert scripts and the following "$txtRow.i" won't work for ($i = 1; $i <= 10; $i++) { INSERT INTO test values($txtRow.i) } Any suggestions are welcome...If you think you still need to see the whole code i can post it too. Jay
×
×
  • 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.