Jump to content

pmorrison

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

pmorrison's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi, I am trying to create an option to vote on a subject. I have created a form like so: [code] <form method="get" action="place_vote.php"> <b> Please place your vote for this article<p> <input type="radio" name="vote" value="1"> 1 Worst <br /> <input type="radio" name="vote" value="2"> 2 <br /> <input type="radio" name="vote" value="3"> 3 <br /> <input type="radio" name="vote" value="4"> 4 <br /> <input type="radio" name="vote" value="5"> 5 Best <br /> <br /> <input type="submit" value="Vote"> </b> </form> [/code] However, I also want to send the value of the title of the article from the form. I added a new input [code] <input type="hidden" name="article" value=$_GET['title']> [/code] but using the title like this done not work. I know that this GET call does work because further up in the code I do the following and it works fine: [code] <?php include ("phpFunctions.inc"); $title = $_GET['title']; echo("<title>Article: $type</title>"); ?> [/code] The problem is that it sends article=%24title rather than the correct title. I dont know why this wont work, so any help would be much appreciated! Cheers, Paul
  2. I have been looking into using text files with PHP and I am wondering if I need some kind of delimiter to show PHP that it is a new line. Currently each postcode is on a separate line, but just separated using a usual return, no \n or any other delimiter. Could this be a problem? Paul
  3. Hi Ray, I tried it without the / but it then doesnt load the page when I click on the submit button, I get a blank page with just the header. However, when I comment out the $arrFp = file( $filename ); line it loads Ok, but obviously doesnt look at the file. Paul
  4. Hi, I am trying to access a text file which contains a list of postcodes, each on a separate line. I want to go through this file, checking to see if the postcode entered is valid. I tried using it, but realised that it wasnt searching the file correctly. I have put in the line echo "$numLines"; to see how many lines it says are in the text file, it says there is only 1, but I know there are more. Am I trying to access the file incorrectly? I have put the list.txt file in the same directory as the php file. Cheers, Paul $filename = "/list.txt"; // File which holds all data $inputString = $postcode; $arrFp = file( $filename ); // Open the data file as an array $numLines = count( $arrFp ); // Count the elements in the array $numWords = count( $arrWords ); // Count the words in the string for($j=0; $j<$numLines; $j++) { echo "$numLines"; $outputstring = "not found"; if(strstr($inputString, trim( $arrFp[$j] ))) { $errorlist = errorlist('Please fill in the "Postcode" field with a valid postcode', $errorlist); $errorform = 1; $postcodestyle = ' ; color:red'; $outputstring = "found it"; } echo $outputString; // Echo the string replacing restricted words } }
  5. Ive had a go at changing this around, adding in the form tag, but I dont know if Ive put it in the right place, I feel Im out of my php depth! I Told a friend Id be able to do this for him, thinking it would be easy, but it appears I misjudged it! <?php require_once('member_auth.php') ; include_once('../includes/connect_db.php'); include_once('../includes/functions.php'); include('../header.php'); ?> <?php //If user has applied for a subsciption, run this code // If all is OK, then make a subscription if ($_REQUEST['stop_subscription']==1) { if (count($_REQUEST['deletethis']) > 0) { // Split the subscriptions array so we can get the checkbox values. foreach ($_POST['deletethis'] as $sub=>$value) { // stop_subscription.php?id="$" } } } ?> <div id="title1" align="center"> <h3>Unsubscribe</h3> <?php // Make table if member has specific injustice subscriptions $sql = "SELECT i.type, i.title , s.inj_id FROM inj_subscription s, injustices i WHERE s.member_id = '$user' AND i.inj_id = s.inj_id AND s.inj_id IS NOT null" ; $result = mysql_query($sql); $row = mysql_fetch_assoc($result) ; if ($row) { echo "<div><span>Specific Injustice Subsriptions:</span><br/>" ; $table_start ='<table width="90%" table name="table2" align="center" cellspacing="0" border="0"> <tr> <form method="post" action="stop_subscription.php"> <th width="20%">Type</th> <th width="70%">Title</th> <th width="10%"></th> <input type="submit" name="Submit" value="Submit" style="font-size:10px"/><p> <input type="hidden" name="stop_subscription" value="1"/> </form> </tr>'; echo $table_start; $rownum = 0; while($row) { $rownum++; $style = rowcolor($rownum); $table_rows = "<td id=\"td\" align=\"center\" style=\" $style ;padding:5px\" >" .$row['type'] . "</td>"; $table_rows .= "<td id=\"td\" align=\"center\" style=\" $style ;padding:5px\" >" . $row['title']. "</td> \n\t"; $table_rows .= '<td id="td" align="center" style="'.$style.';padding:5px;" >'."\n".'<input type="checkbox" name="deletethis[]" value="'.$row['inj_id'] . '"></td>'."\n\t"; echo "<tr>" . $table_rows . "</tr>"; $row = mysql_fetch_assoc($result) ; } echo '</table><Br/></div><br/>'; } ?> </div> <?php include('../footer.php'); ?>
  6. Hi, I am new to Javascript and am having a bit of difficulty. On my site, in order for a member to unsubscribe from an article, they go to the'Unsubscribe' page where they get a table of all of the articles that they are subscribed to. There is a table with each article, and a checkbox next to each article. For each checked checkbox it should send the value of the checkbox to stop_subscription.php. I have used the following javascript, I know there is something wrong with it, but dont know what: <script type="text/javascript"> function validate() { for(var i=0; i < document.table11.deletethis[].length; i++){ if(document.table1.deletethis[i].checked) stop_subscription.php?id="document.form1.deletethis[i].value" } } </script> Here are other bits of code I think might be relevant: <?php // Make table if member has specific injustice subscriptions $sql = "SELECT i.type, i.title , s.inj_id FROM inj_subscription s, injustices i WHERE s.member_id = '$user' AND i.inj_id = s.inj_id AND s.inj_id IS NOT null" ; $result = mysql_query($sql); $row = mysql_fetch_assoc($result) ; if ($row) { echo "<div><span>Specific Injustice Subsriptions:</span><br/>" ; $table_start ='<table width="90%" table name="table2" align="center" cellspacing="0" border="0"> <tr> <th width="20%">Type</th> <th width="70%">Title</th> <th width="10%"></th> <input type=button name="Unsubscribe" value="Unsubscribe" onClick="validate()" style="font-size:10px"/><p> </tr>'; echo $table_start; $rownum = 0; while($row) { $rownum++; $style = rowcolor($rownum); $table_rows = "<td id=\"td\" align=\"center\" style=\" $style ;padding:5px\" >" .$row['type'] . "</td>"; $table_rows .= "<td id=\"td\" align=\"center\" style=\" $style ;padding:5px\" >" . $row['title']. "</td> \n\t"; $table_rows .= '<td id="td" align="center" style="'.$style.';padding:5px;" >'."\n".'<input type="checkbox" name="deletethis[]" value="'.$row['inj_id'] . '"></td>'."\n\t"; echo "<tr>" . $table_rows . "</tr>"; $row = mysql_fetch_assoc($result) ; } echo '</table><Br/></div><br/>'; } ?> I feel bad just pasting a large slab of code here, but I really have no idea where Im going wrong! Cheers, Paul
×
×
  • 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.