Jump to content

dp2

Members
  • Posts

    16
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

dp2's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I think we are moving towards a final solution! Updating data using a php form to MYSQL table I'm stuck here: $query="SELECT * FROM systemsdoc WHERE id = \"".$formVars["id"]."\""; $result=mysql_query($query); $row=mysql_fetch_array($result); I'm getting Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource Its pointing to line 9 $row=mysql_fetch_array($result); <?php foreach($HTTP_POST_VARS as $varname => $value) $formVars[$varname]=$value; require_once("dbc1.php"); $db1=mysql_connect($dbhost, $dbuname, $dbpass); mysql_select_db("regdir"); $query="SELECT * FROM regdirWHERE id = \"".$formVars["id"]."\""; $result=mysql_query($query); $row=mysql_fetch_array($result); $formVars = array(); $formVars["BusinessName"]=$row["BusinessName"]; $formVars["BusinessStreet"]=$row["BusinessStreet"]; $formVars["Town"]=$row["Town"]; $formVars["PostCode"]=$row["PostCode"]; $formVars["Telephone"]=$row["Telephone"]; $formVars["joined"]=$row["joined"]; $formVars["UserEmail"]=$row["UserEmail"]; $formVars["Mobile"]=$row["Mobile"]; $formVars["user_pwd"]=$row["user_pwd"]; $formVars["Web"]=$row["Web"]; $formVars["id"]=$row["id"]; mysql_close($db1); ?> Please could someone point me in the right direction
  2. Work in progress - I managed to pull data into a form <HTML> <HEAD> <TITLE> The Edit Directory Listing</TITLE> <HEAD> <BODY> <?php $dbcnx = @mysql_connect("localhost", "username", "password"); if (!$dbcnx) { echo( "<P>Unable to connect to the" . "database server at this time.</P>" ); exit(); } //select which database you want to edit mysql_select_db("aynsley_phpbb1",$dbcnx); if (! @mysql_select_db("aynsley_phpbb1") ) { echo( "<P>Unable to locate the regdir " . "database at this time.</P>" ); exit(); } // Request the text of all the business names $result = mysql_query( "SELECT BusinessName FROM regdir"); if (!$result) { echo("<P>Error performing query: " . mysql_error() . "</P>"); exit(); } //mysql_query(<query>, <connection id>); while ($row=mysql_fetch_array($result)) { list ($BusinessStreet, $BusinessName) = $row; } // Request the text of all the business names $result = mysql_query("SELECT * FROM regdir"); if (!$result) { echo("<P>Error performing query: " . mysql_error() . "</P>"); exit(); } // Display the text of each BusinessName in a paragraph while ( $row = mysql_fetch_array($result) ) { list ($BusinessName, $BusinessStreet) = $row; } ?> <html> <body> <form method="post"action="<?php echo $PHP_SELF ?>"> Business Name: <input type=text name="BusinessName" value="<?PHP echo $BusinessName ?>"><br> Business Street: <input type=text name="BusinessStreet" value="<?PHP echo $BusinessStreet ?>"><br> <input type=submit name="submit" value="submit"> </form> </BLOCKQUOTE> </BODY> </HTML> Is there a method to simplfy and condense further
  3. This is a modified script to fetch the data and display into the form for editing then to write to the fields. However the script is not loading the data into the form <?php session_start(); if (!isset($_SESSION['user'])) { header("Location: login.php"); } include ('dbc.php'); $directory_tablename = 'regdir'; // table $link_id = 0; $category_id_length = 3; $root_category_id = '000'; $max_desc_length = 250; $new_window_width = 600; $new_window_height = 500; $welcome_message = "Welcome to the Directory!"; $records_per_page = 3; $num_top_sites = 5; $num_new_sites = 5; $admin_script = 'dir_manager.php'; $send_mail = False; $dirmaster_email = "dirmaster<admin@xxxx>"; $MYSQL_ERRNO = ''; $MYSQL_ERROR = ''; function modify_url_form() { global $PHP_SELF, $id, $BusinessName, $BusinessStreet, $User_pwd; //directory_header(); //if(basename($PHP_SELF) == $admin_script) $admin = 1; $url_info_array = get_url_info($id); //$category_info_array = get_category_info($url_info_array["id"]); } ?> <CENTER><H3>Update your PHP site!</H3></CENTER> <FORM METHOD="POST" ACTION="<?php echo $PHP_SELF ?>"> <INPUT TYPE="HIDDEN" NAME="action" VALUE="web"> <INPUT TYPE="HIDDEN" NAME="id" VALUE="<?php echo $id ?>"> <INPUT TYPE="HIDDEN" NAME="BusinessName" VALUE="<?php echo $BusinessName ?>"> <CENTER><TABLE BORDER="1" WIDTH="90%"> <TR> <TH WIDTH="20%" NOWRAP>BusinessName</TH> <TD WIDTH="80%"><?php echo $url_info_array["BusinessName"] ?></TD> </TR> <TR> <TH WIDTH="20%" NOWRAP>user_pwd</TH> <TD WIDTH="80%"><INPUT TYPE="TEXT" NAME="user_pwd" SIZE="30" MAXLENGTH="150"></TD> </TR> <TR> <TH WIDTH="20%" NOWRAP>BusinessStreet</TH> <TD WIDTH="80%"><INPUT TYPE="PASSWORD" NAME="BusinessStreet" SIZE="20" MAXLENGTH="20"></TD> </TR> <TR> <TH WIDTH="20%" NOWRAP>Town</TH> <TD WIDTH="80%"><INPUT TYPE="TEXT" NAME="Town" VALUE="<?php echo $url_info_array["Town"] ?>" SIZE="30" MAXLENGTH="150"></TD> </TR> <TR> <TH WIDTH="20%" NOWRAP>UserEmail</TH> <TD WIDTH="80%"><INPUT TYPE="TEXT" NAME="UserEmail" VALUE="<?php echo "".$UserEmail["UserEmail"];?>" SIZE="30" MAXLENGTH="150"></TD> </TR> <TR> <TH WIDTH="20%" NOWRAP>Web<BR> (<?php echo $max_desc_length ?> Chars Max.) </TH> <TD WIDTH="80%"><TEXTAREA NAME="web" ROWS="5" COLS="40"> <?php echo $url_info_array["web"] ?> </TEXTAREA></TD> </TR> <TR> <TH WIDTH="100%" NOWRAP COLSPAN="2"> <INPUT TYPE="SUBMIT" VALUE="Modify URL" NAME="Submit"> <INPUT TYPE="RESET" VALUE="Reset"></TH> </TR> </TABLE> </CENTER> </FORM> <?php // directory_footer(); //} function modify_url() { //display all the news $result = mysql_query("select * from BusinessName order by id"); //run the while loop that grabs all the data scripts while($r=mysql_fetch_array($result)) { //grab the title and the ID of the news $title=$r["BusinessStreet"];//take out the title $id=$r["id"];//take out the id //make the title a link echo "<a href='edit.php?cmd=edit&id=$id'>$title - Edit</a>"; echo "<br>"; } if(empty($BusinessName)) error_message("Please enter the Business Name!"); if(empty($Web)) error_message("Please enter the URL!"); if(empty($Message1)) error_message("Please enter the description!"); if(strlen($Message1) > $max_desc_length) error_message("Description too long! 150 chars max!"); $url_info_array = get_url_info($id); if(!$admin && (($url_info_array["user_pwd"] != crypt($user_pwd, '.v')) || ($url_info_array["UserEmail"] != $email))) error_message("You don't have permission to modify this URL!"); $BusinessName = addslashes($BusinessName); $Message1 = addslashes($Message1); if(!$link_id) $link_id = db_connect($default_dbname); $query = "UPDATE regdir SET BusinessName='$BusinessName', Web='$Web', Message1='$Message1' WHERE id='$id'"; $result = mysql_query($query); if(!$result) error_message(sql_error()); $num_rows = mysql_affected_rows($link_id); if($num_rows != 1) error_message(sql_error()); else echo "<SCRIPT>alert(\"$BusinessName($Web) has been successfully modified!\"); opener.location.href='$PHP_SELF?action=show_list&id=$id&cur_page=$cur_page'; self.close();</SCRIPT>"; }
  4. Thank you for explaining the errors, I know now where the test script was failing. 1)I was trying to call once yet there were two calls and one was missing the $result query 2) There was a brace missing which I have corrected This code now works with two calls <HTML> <HEAD> <TITLE> The Reg Directory </TITLE> <HEAD> <BODY> <?php $dbcnx = @mysql_connect("localhost", "username", "password"); if (!$dbcnx) { echo( "<P>Unable to connect to the" . "database server at this time.</P>" ); exit(); } //select which database you want to edit mysql_select_db("aynsley_phpbb1",$dbcnx); if (! @mysql_select_db("aynsley_phpbb1") ) { echo( "<P>Unable to locate the regdir " . "database at this time.</P>" ); exit(); } // Request the text of all the business names $result = mysql_query( "SELECT BusinessName FROM regdir"); if (!$result) { echo("<P>Error performing query: " . mysql_error() . "</P>"); exit(); } //mysql_query(<query>, <connection id>); while ($row=mysql_fetch_array($result)) { echo("<P>" . $row["BusinessName"] . "</P>"); } ?> <P> Here are all the Businesses in our database: </P> <BLOCKQUOTE> <?php // Request the text of all the business names $result = mysql_query( "SELECT BusinessStreet FROM regdir"); if (!$result) { echo("<P>Error performing query: " . mysql_error() . "</P>"); exit(); } // Display the text of each BusinessName in a paragraph while ( $row = mysql_fetch_array($result) ) { echo("<P>" . $row["BusinessStreet"] . "</P>"); } ?> </BLOCKQUOTE> </BODY> </HTML> Now back to my original script. What I am trying to attempt is pull the field data into a form fields to edit and then submit the edited data in the database field. Ideally I'm aiming for a user to be able to edit their account details but for now I'm happy for an admin script. 1) A form to pull row by id 2) A form with row data for editing 3) Form handler to update or write to id row I'm sure this can be achieved in one script My first problem is echo the data into the form fields <?PHP echo("<P>" . $row["BusinessName"] . "</P>"); ?> }
  5. Exhausted all your suggestions even reverted to this basic test script: Parse error: syntax error, unexpected $end on line 50 <HTML> <HEAD> <TITLE> The Reg Directory </TITLE> <HEAD> <BODY> <?php $dbcnx = @mysql_connect("localhost", "aynsley", "54321dkp"); if (!$dbcnx) { echo( "<P>Unable to connect to the" . "database server at this time.</P>" ); exit(); } //select which database you want to edit mysql_select_db("aynsley_phpbb1",$dbcnx); if (! @mysql_select_db("aynsley_phpbb1") ) { echo( "<P>Unable to locate the regdir " . "database at this time.</P>" ); exit(); } //mysql_query(<query>, <connection id>); while ($row=mysql_fetch_array($result,MYSQL_NUM)) { echo("<P>" . $row["id"] . "</P>"); ?> <P> Here are all the Businesses in our database: </P> <BLOCKQUOTE> <?php // Request the text of all the business names $result = mysql_query( "SELECT BusinessName FROM regdir"); if (!$result) { echo("<P>Error performing query: " . mysql_error() . "</P>"); exit(); } // Display the text of each BusinessName in a paragraph while ( $row = mysql_fetch_array($result) ) { echo("<P>" . $row["BusinessName"] . "</P>"); } ?> </BLOCKQUOTE> </BODY> </HTML> Now this is weird I commented out while ( $row = mysql_fetch_array($result) ) { No more errors and displays the correct data pulled from the database <HTML> <HEAD> <TITLE> The Reg Directory </TITLE> <HEAD> <BODY> <?php $dbcnx = @mysql_connect("localhost", "aynsley", "54321dkp"); if (!$dbcnx) { echo( "<P>Unable to connect to the" . "database server at this time.</P>" ); exit(); } //select which database you want to edit mysql_select_db("aynsley_phpbb1",$dbcnx); if (! @mysql_select_db("aynsley_phpbb1") ) { echo( "<P>Unable to locate the regdir " . "database at this time.</P>" ); exit(); } //mysql_query(<query>, <connection id>); //while ($row=mysql_fetch_array($result,MYSQL_NUM)) { echo("<P>" . $row["id"] . "</P>"); ?> <P> Here are all the Businesses in our database: </P> <BLOCKQUOTE> <?php // Request the text of all the business names $result = mysql_query( "SELECT BusinessName FROM regdir"); if (!$result) { echo("<P>Error performing query: " . mysql_error() . "</P>"); exit(); } // Display the text of each BusinessName in a paragraph while ( $row = mysql_fetch_array($result) ) { echo("<P>" . $row["BusinessName"] . "</P>"); } ?> </BLOCKQUOTE> </BODY> </HTML> Any reasons why this fixes the problem? I''m going to go back and test my original script to see if this is a fix
  6. Thank you for the referal This is the code which half works with errors Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/aynsley/public_html/1pw/3/edit.php on line 17 - Edit Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/aynsley/public_html/1pw/3/edit.php on line 39 Data from the fields are not displaying in each form box <? //connect to mysql //change user and password to your mySQL name and password mysql_connect("localhost","xxxxxx","xxxxxxx"); //select which database you want to edit mysql_select_db("regdir"); //If cmd has not been initialized if(!isset($cmd)) { //display all the news $result = mysql_query("select * from regdir WHERE id = $id"); } { //run the while loop that grabs all the news scripts [color=red]while($row = mysql_fetch_array($result)){[/color] } { //grab the title and the ID of the news $BusinessName=$r["BusinessName"];//take out the title $id=$r["id"];//take out the id //make the title a link echo "<a href='edit.php?cmd=edit&id=$id'>$BusinessName - Edit</a>"; echo "<br>"; } ?> <? if($_GET["cmd"]=="edit" || $_POST["cmd"]=="edit") { if (!isset($_POST["submit"])) { $id = $_GET["id"]; $sql = "SELECT * FROM regdir WHERE id=$id"; $result = mysql_query($sql); [color=blue]$id = mysql_fetch_array($result);[/color] ?> <HTML> <body> <form action="edit.php" method="post"> <input type=hidden name="id" value="<?php echo $id["id"] ?>"> Business Name:<INPUT TYPE="TEXT" NAME="BusinessName" VALUE="<?php echo $id["BusinessName"] ?>" SIZE=30><br> Town:<TEXTAREA NAME="Town"COLS=30><?php echo $id["Town"] ?></TEXTAREA><br> Telephone:<INPUT TYPE="TEXT" NAME="Telephone" VALUE="<?php echo $id["Telephone"] ?>" SIZE=30><br> <input type="hidden" name="cmd" value="edit"> <input type="submit" name="submit" value="submit"> </form> </body> </html> <?php } ?> <?php if ($_POST["$submit"]) { $BusinessName = $_POST["BusinessName"]; $Town = $_POST["Town"]; $Telephone = $_POST["Telephone"]; $sql = "UPDATE regdir SET BusinessName='$BusinessName',Town='$Town',Telephone='$Telephone' WHERE id=$id"; //replace news with your table name above $result = mysql_query($sql); echo "Thank you! Information updated."; } } } ?> I have attempted to solve for open and closed braces with no joy
  7. Objective: PHP form that fetches data from database tables and allows me to edit via a form. I have tried a number of tutorials on the net but have failed to get their sample code to work mainly they are poor outdated coding versions in php3 to php4. Trying to establish the current and correct way to pull data, edit and update. I notice that they have been using three files to perform this 1) Form to fetch the ID row contents and display in next form 2) Displays the row for editing form and sent to the handler 3) form handler that processes the data and writes it to the database Some manage to include the three files in one php file. This is where it gets complicated. The following snip bit of code works by displaying the contents but I need to display the data into a form so that I can edit the data and write it back to the database. $query="SELECT * FROM regdir"; $result=mysql_query($query); while($row=mysql_fetch_array($result,MYSQL_ASSOC)) { ECHO "BusinessName:{$row['BusinessName']}<br>". "BusinessStreet:{$row['BusinessStreet']} <br>". "Town:{$row['Town']} <br><br>"; } Once I have a basic script working I can learn from I can build on. This is what I have been working on <?php include ('dbc.php'); //$db=mysql_connect($dbhost, $dbuname, $dbpass); //mysql_select_db("$dbname"); $query="SELECT * FROM regdir"; $result=mysql_query($query); while($row=mysql_fetch_array($result,MYSQL_ASSOC)) { ECHO "BusinessName:{$row['BusinessName']}<br>". "BusinessStreet:{$row['BusinessStreet']} <br>". "Town:{$row['Town']} <br><br>"; } //include 'closedb.php'; $_GET["BusinessName"]=$row["BusinessName"]; $_GET["BusinessStreet"]=$row["BusinessStreet"]; $_GET["Town"]=$row["Town"]; $_GET["PostCode"]=$row["PostCode"]; $_GET["Telephone"]=$row["Telephone"]; $_GET["joined"]=$row["joined"]; $_GET["UserEmail"]=$row["UserEmail"]; $_GET["Mobile"]=$row["Mobile"]; $_GET["user_pwd"]=$row["user_pwd"]; $_GET["Web"]=$row["Web"]; $_GET["id"]=$row["id"]; //mysql_close($db); ?> <html> <head> <title>SystemsDoc Update</title> </head> <body bgcolor="white"> <form method="post" action="postupdate.php"> <table> <col span="1" align="right"> <tr> <td><font color="blue">BusinessName:</font></td> <td><input type="text" name="BusinessName" value="{$row['BusinessName']}" size=100></td> </tr> <tr> <td><font color="blue">BusinessStreet:</font></td> <td><input type="text" name="BusinessStreet" value="<? echo $_GET["BusinessStreet"]; ?>" size=100></td> </tr> <tr> <td><font color="blue">Town:</font></td> <td><input type="text" name="Town" value="<? echo $_GET["Town"]; ?>" size=100></td> </tr> <tr> <td><font color="blue">PostCode:</font></td> <td><input type="text" name="PostCode" value="<? echo $_GET["PostCode"]; ?>" size=100></td> </tr> <tr> <td><font color="blue">Telephone:</font></td> <td><input type="text" name="Telephone" value="<? echo $_GET["Telephone"]; ?>" size=100></td> </tr> <tr> <td><font color="blue">joined Date:</font></td> <td><input type="text" name="joined" value="<? echo $_GET["joined"]; ?>" size=100></td> </tr> <tr> <td><font color="blue">UserEmail:</font></td> <td><input type="text" name="UserEmail" value="<? echo $_GET["UserEmail"]; ?>" size=100></td> </tr> <tr> <td><font color="blue">Mobile:</font></td> <td><input type="text" name="Mobile" value="<? echo $_GET["Mobile"]; ?>" size=100></td> </tr> <tr> <td><font color="blue">user_pwd:</font></td> <td><input type="text" name="user_pwd" value="<? echo $_GET["user_pwd"]; ?>" size=100></td> </tr> <tr> <td><font color="blue">Web:</font></td> <td><input type="text" name="Web" value="<? echo $_GET["Web"]; ?>" size=100></td> </tr> <tr> <td><font color="blue">id:</font></td> <td><input type="text" name="id" value="<? echo $_GET["id"]; ?>" size=100></td> </tr> <tr> <td><input type="submit" value="Submit"></td> </tr> </body> </html> Any ideas where I am getting wrong
  8. dp2

    mcrypt

    I am trying to read a flat file and echo each line. The data also contains encrypted passwords which I wish to decyfer. But my script is displaying the following warning: Warning: mcrypt_generic_init(): Iv size incorrect; supplied length: 4, needed: 8 in /home/aynsley/public_html/1pw/see_users.php on line 25 dp2 $1$qrBh7zJ8$x5VTTg8qmb1EW7hiXxP9J1 8œä ‚ The script <?php if ($file_array = @file ("./users.txt")) { // Read the file into an array. // **** Mcrypt ***** // Create a key. $mcrypt_key = "Hey! Here's the KEY.1776"; // Open and initialize Mcrypt. $mcrypt_module = mcrypt_module_open (MCRYPT_TripleDES, "", MCRYPT_MODE_CBC, ""); foreach ($file_array as $key => $value) { // Loop through each line. $line = explode ("\t", $value); // Decrypt the data. [color=red]$mcrypt_iv = base64_decode (trim($line[3])); mcrypt_generic_init ($mcrypt_module, $mcrypt_key, $mcrypt_iv);[/color] $data = mdecrypt_generic ($mcrypt_module, base64_decode($line[2])); echo "<pre>$line[0] $line[1] $data</pre><p></p>\n"; // Print the data. } // Close Mcrypt. mcrypt_generic_end ($mcrypt_module); } else { // If it couldn't read the file, print an error message. echo "Could not read the users file!<br />"; } ?> How do I increase the IV size?
  9. Are there more productive methods to consider in this plan? I have added some ideas but I could be totally wrong. I'm calling the project a Token/affiliate script with a public directory. Aims & Objectives: My subscribed members are retailers, dealers and buyers who will be given the option to earn rewards points, discounts or commission for every new member that subscribes from their referral. This introduction is conducted outside the internet but confirmed through the internet site. There will be an incentive for new subscribers to use the promotion code in order to qualify for the discount on the subscription service. At the same time a record is needed and a method to process successfully paid subscribers and add achieved points/discounts/commissions to the referrer. The referrer will be able to check online via their account their commissions achieved. The script will generate a unique code for each member to use in their promotion invitation. When a referral registers with this unique code they obtain a discount to their subscription and also the referral points/commission are added to the retailers account. How the script maybe planned out: I'm thinking breaking down the script into each of its functions. With flat files in mind each function will have it’s own flat file. 1)AUTHENTICATION 2)DIRECTORY/PROFILE 3)PROMOTION CODE 4)REWARD POINTS COUNTER – 5)PAYMENT PLANS Keeping things to a minimum using a flat file database that can be extended to a mysql database 1) Standard authentication/Registration script for member login in and out - Simple form to text file. ID reference number could be generated as the promotion code 2) Form with Opt in or out of the PUBLIC DIRECTORY and profile details, - Form adds contents to profile text file. 3) Promotion code is generated at time of registration or added by admin. The code could be generated by encryption of the retailers username, or a list of codes placed in a text file where a retailer ID number is added next to the code. Promocode ReferID GJ5GDHGRA | 000353 4)Reward points are added using a basic counter script - Form searches promotion code and records visit in referrers profile. Paypal link for discount subscription. Confirmed to admin via Paypal email, Admin adds the points manually to the referrers account. Not sure if points could be added automatically to referrer’s account. 5) Admin will manually or allow approved commissions to be paid via Paypal or sent cheque. I will need to do a little research to establish if this can be automated to make monthly total payments. The directory - The main purpose of the directory is for buyers to locate their nearest retailers and dealers via a postcode or County search. At the same time Retailers and dealers can edit their free listing on the directory. This could be a module to add to. But I have included this because It may affect the planning of the affiliation script. Any pointers will help
  10. Could some one point me in the right direction. Firstly, I would like to find out how to add a set number say 10, via a form to a flat file field that not only deletes and replace but to add the existing number together to produce a total. A sort of counter in units of 10. I'm working on a simple afflicate script that adds rewards points to a registerd user who has refered a new user to a basic subscription service. The new user types in the users unique promotion code and is directed to a page that offers a discounted rate (A page with a Paypal button link) The promotion code I thought could be the userid number to access the correct line and then adds the points. I can add the points to the field but it replaces the other record. In general what are all the calculation possibilities Thanks
  11. This example maybe a more easier approach for swish max just compare your code against this As you know your submit button Action script code: on (press) { //checks if the fields are empty if so shows the error message if (Name=="" or Email=="" or Message=="") { info="Error Sending Message" //checks if the name is more than 2 letters most names are more than 2 letters long //if not shows the error message; } else if (Name.length < 2) { info="Error Sending Message"; } //checks if the Email is more than 3 letters most email addresses are more than 3 letters long //if not shows the error message; else if (Email.length < 3) { info="Error Sending Message"; } //checks that an @ has been entered into the Email Field //if not shows the error message else if (Email.indexOf("@") == -1) { } //checks that an . has been entered into the Email Field //if not shows the error message else if (Email.indexOf(".") == -1) { } //checks that the message is at least 10 letters long //if not shows the error message else if (Message.length < 10) { info="Error Sending Message"; } //if everything has passed the checks it loads the variables //and sends the message else{ info="Message Was Sent"; loadVariables("send.php",'POST'); } } Your external flat file named file:flashq.php can replace the send.php The external file referenced in the submit button: <?php $EmailFrom = "your email address"; $EmailTo = "your email address"; $Subject = "Form submitted from site"; $Name = Trim(stripslashes($_POST['Name'])); $Email = Trim(stripslashes($_POST['Email'])); $Message = Trim(stripslashes($_POST['Message'])); $Body = ""; $Body .= "Name: "; $Body .= $Name; $Body .="\n"; $Body .= "Email: "; $Body .= $Email; $Body .="\n"; $Body .= "Message: "; $Body .= $Message; $Body .="\n"; $success -mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); ?> Info box which provides the user error or sent message in response to submitting the form this action script is placed in the scene root and a info box created using the text tool and selecting: Input Text. onLoad () {// carries the function out once Name="";//clears the Name box Email="";//clears the Email box Message="";//clears the Message box info="";//clears the info box } If you can get this script to work then all you do is add the extra fields as required. For a button to reset the form the action script is as follows: on (press) {// carries the function out when button is clicked Name="";//clears the Name box Email="";//clears the Email box Message="";//clears the Message box info="";//clears the info box }
  12. The first part of the code checks the username input into the form field. I understand that if empty of anything it prints/displays an error message refering to the language file. If a username is typed and it matches in the database field it prints/displays "username already taken." If the username does not match it is accepted and goes onto the next form field. This is the complexities with postnuke I need even if I use a drop down menu list that a selection has been made. I am wondering If I duplicate this code and modify by adding $location and user_from this should in some way do the same as username.
  13. Deepest apologises for not placing the code in the code button. First time round I could not find it. # :-) button Thanks for the pointer, so I am assuming the code goes some where here // some input checking if (!pnSecAuthAction(0, 'UserInfo::', '::', ACCESS_READ)) { echo _PERMISSIONSNOAUTH; include 'footer.php'; exit; } if ( empty($uname) || stristr($uname,'&') || preg_match("/[[:space:]]/", $uname) || strip_tags($uname) != $uname) { echo _MODARGSERROR; include 'footer.php'; exit; } // End of check I'm not sure about your code, If I were to duplicate the above and edit the dummy variables it could work? But, I have a sneeky feeling the above maybe incorrect too, because there is a function that checks the username entered against the database to see if the username already exists. The error message is referenced to the language file _MODARGSERROR Back to your code, I know that I am not requesting validation here just that something is typed into this field What about this code: if (eregi ("^([[:alpha:]]|-|')+$", $HTTP_POST_VARS[location])) { $location = TRUE; } else { $location = false; $message[] = "Please enter a valid location."; } Which also checks for a apostrophe. getting a bit distracted if (!isset (<<name of the location form field>>)) {blah blah blah;} else {blah blah blah;} How about this example: if (isset($HTTP_POST_VARS[submit])){ Or maybe I'm barking up the wrong tree if (!isset (<<user_from>>)) {blah blah blah;} else {Please type your location;} or if (!pnSecAuthAction(0, 'user_from::', '::', ACCESS_READ)) { echo _PERMISSIONSNOAUTH; include 'footer.php'; exit; }
  14. This is the full code of the page: <?php // File: $Id: user.php 19273 2006-06-22 19:05:48Z markwest $ // ---------------------------------------------------------------------- // PostNuke Content Management System // Copyright © 2001 by the PostNuke Development Team. // http://www.postnuke.com/ // ---------------------------------------------------------------------- // Based on: // PHP-NUKE Web Portal System - http://phpnuke.org/ // Thatware - http://thatware.org/ // ---------------------------------------------------------------------- // LICENSE // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License (GPL) // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // To read the license please visit http://www.gnu.org/copyleft/gpl.html // ---------------------------------------------------------------------- // Original Author of file: // Purpose of file: // ---------------------------------------------------------------------- if (!defined('LOADED_AS_MODULE')) { die ('You can\'t access this file directly...'); } $ModName = basename(dirname(__FILE__)); modules_get_language(); function user_user_userinfo() { $dbconn =& pnDBGetConn(true); $pntable =& pnDBGetTables(); $uname = pnVarCleanFromInput('uname'); include 'header.php'; // some input checking if (!pnSecAuthAction(0, 'UserInfo::', '::', ACCESS_READ)) { echo _PERMISSIONSNOAUTH; include 'footer.php'; exit; } if ( empty($uname) || stristr($uname,'&') || preg_match("/[[:space:]]/", $uname) || strip_tags($uname) != $uname) { echo _MODARGSERROR; include 'footer.php'; exit; } // End of check $column = &$pntable['users_column']; $sql = "SELECT $column[femail] AS femail, $column AS url, $column[bio] AS bio, $column[user_avatar] AS user_avatar, $column[user_icq] AS user_icq, $column[user_aim] AS user_aim, $column[user_yim] AS user_yim, $column[user_msnm] AS user_msnm, $column[user_from] AS user_from, $column[user_occ] AS user_occ, $column[user_intrest] AS user_intrest, $column[user_sig] AS user_sig, $column[uid] AS pn_uid, $column[pass] AS pass FROM $pntable[users] WHERE $column[uname]='" . pnVarPrepForStore($uname) . "'"; $result =& $dbconn->Execute($sql); $userinfo = $result->GetRowAssoc(false); OpenTable(); echo '<h2>' . pnVarPrepForDisplay($uname) . '</h2>'; if ((!$result->EOF) && ($userinfo['url'] || $userinfo['femail'] || $userinfo['bio'] || $userinfo['user_avatar'] || $userinfo['user_icq'] || $userinfo['user_aim'] || $userinfo['user_yim'] || $userinfo['user_msnm'] || $userinfo['user_from'] || $userinfo['user_occ'] || $userinfo['user_intrest'] || $userinfo['user_sig'] || $userinfo['pn_uid'])) { echo '<div style="text-align:center">'; $userinfo['user_sig'] = nl2br($userinfo['user_sig']); if ($userinfo['user_avatar']) { echo '<img src="images/avatar/'.pnVarPrepForDisplay($userinfo['user_avatar']).'" alt="" /><br />'."\n"; } echo _REGISTEREDUSER." ".pnVarPrepForDisplay($userinfo['pn_uid']).'<br />'."\n"; if ($userinfo['url']) { echo _MYHOMEPAGE . ' <a href="'.pnVarPrepForDisplay($userinfo['url']).'">' . pnVarPrepForDisplay($userinfo['url']) . '</a><br />'."\n"; } if ($userinfo['femail']) { echo _MYEMAIL . ' <a href="mailto:'.pnVarPrepForDisplay($userinfo['femail']).'">' . pnVarPrepForDisplay($userinfo['femail']) . '</a><br />'."\n"; } if ($userinfo['user_icq']) { echo _ICQ . ': ' . pnVarPrepForDisplay($userinfo['user_icq']) . '<br />'."\n"; } if ($userinfo['user_aim']) { echo _AIM . ': ' . pnVarPrepForDisplay($userinfo['user_aim']) . '<br />'."\n"; } if ($userinfo['user_yim']) { echo _YIM . ': ' . pnVarPrepForDisplay($userinfo['user_yim']) . '<br />'."\n"; } if ($userinfo['user_msnm']) { echo _MSNM . ': ' . pnVarPrepForDisplay($userinfo['user_msnm']) . '<br />'."\n"; } if ($userinfo['user_from']) { echo _LOCATION . ': ' . pnVarPrepForDisplay($userinfo['user_from']) . '<br />'."\n"; } if ($userinfo['user_occ']) { echo _OCCUPATION . ': ' . pnVarPrepForDisplay($userinfo['user_occ']) . '<br />'."\n"; } if ($userinfo['user_intrest']) { echo _INTERESTS . ': ' . pnVarPrepForDisplay($userinfo['user_intrest']) . '<br />'."\n"; } if ($userinfo['user_sig']) { echo '<br />' . _SIGNATURE . ":<br />" . pnVarPrepHTMLDisplay($userinfo['user_sig']) . '<br />'."\n"; } if ($userinfo['bio']) { echo '<br />' . _EXTRAINFO . ":<br />" . pnVarPrepForDisplay($userinfo['bio']) . '<br />'."\n"; } $activetime = time() - (pnConfigGetVar('secinactivemins') * 60); $userhack = "SELECT pn_uid FROM ".$pntable['session_info']." WHERE pn_uid = '$userinfo[pn_uid]' AND pn_lastused > '".pnVarPrepForStore($activetime)."'"; $userresult =& $dbconn->Execute($userhack); $online_state = $userresult->GetRowAssoc(false); if (isset($online_state['pn_uid'])) { $online = _ONLINE; } else { $online = _OFFLINE; } echo '<br />'._USERSTATUS.': '.pnVarPrepForDisplay($online).'<br />'."\n"; if (pnModAvailable('Messages')) { echo "<br />[ <a href=\"".pnModURL('Messages', 'user', 'compose', array('uname' => $uname)) ."\">" . _USENDPRIVATEMSG . " " . pnVarPrepForDisplay($uname) . "</a> ]<br />\n"; } if (pnModAvailable('Comments')) { echo '<br />'; user_main_last10com($uname); echo '<br />'; } if (pnModAvailable('News')) { echo '<br />'; user_main_last10submit($uname); } echo '</div>'; } else { echo '<div style="text-align:center">' . _NOINFOFOR . ' ' . pnVarPrepForDisplay($uname) . '</div>'; } CloseTable(); include('footer.php'); } function user_user_login() { list($uname, $pass, $url, $rememberme) = pnVarCleanFromInput('uname', 'pass', 'url', 'rememberme'); if (!isset($rememberme)) { $rememberme = ''; } access_user_login($uname, $pass, $url, $rememberme); } function user_user_getlogin() { // Check if stop var is numeric if ((isset($GLOBALS['stop']) && !empty($GLOBALS['stop']) && !is_numeric($GLOBALS['stop']))) { include 'header.php'; echo _MODARGSERROR; unset($GLOBALS['stop']); include 'footer.php'; exit; } // End of check if ($GLOBALS['stop']) { user_user_loginscreen(_LOGININCOR); } else { include 'header.php'; OpenTable(); echo '<h1>' . _USERREGLOGIN . '</h1>'; CloseTable(); OpenTable(); echo '<h2>'._SELECTOPTION.'</h2>'; echo '<ul>'; echo '<li><a href="user.php?op=loginscreen&module=User">'._LOGINSITE . '</a></li>'; // if admin do not allow register if (pnConfigGetVar('reg_allowreg')) { // age will not be checked, if $pnconfig['minage'] is set to 0 in config.php if (pnConfigGetVar('minage') == 0) { echo '<li><a href="user.php?op=register&module=NewUser">'._REGISTER.'</a></li>'; } else { echo '<li><a href="user.php?op=check_age&module=NewUser">'._REGISTER.'</a></li>'; } } else { echo '<li><strong>'._NOTALLOWREG.'</strong><br />'._REASONS.'<br /> ' . pnVarPrepForDisplay(pnConfigGetVar('reg_noregreasons')) . '</li>'; } echo '<li><a href="user.php?op=lostpassscreen&module=LostPassword">'._RETRIEVEPASS.'</a></li>'; echo '</ul>'; CloseTable(); include ('footer.php'); } } function user_main_last10com($uname) { $dbconn =& pnDBGetConn(true); $pntable =& pnDBGetTables(); $column1 = &$pntable['comments_column']; $column2 = &$pntable['stories_column']; /** * Fetch active laguage */ if (pnConfigGetVar('multilingual') == 1) { $querylang = "AND (" . $column2['alanguage'] . "='" . pnVarPrepForStore(pnUserGetLang()) . "' OR " . $column2['alanguage'] . "='') "; } else { $querylang = ''; } /** * Build up SQL */ $query = "SELECT " . $column1['tid'] . ", " . $column1['sid'] . ", " . $column1['subject'] . " " . "FROM " . $pntable['comments'] . ", " . $pntable['stories'] . " " . "WHERE (" . $column1['name'] . "='" . pnVarPrepForStore($uname) . "' AND " . $column1['sid'] . "=" . $column2['sid'] . ") " . $querylang . "ORDER BY " . $column1['sid'] . " DESC"; /** * Make limited select */ $result = $dbconn->SelectLimit($query, 10, 0); /** * Do output */ OpenTable(); echo '<h2>' . _LAST10COMMENTS . ' ' . pnVarPrepForDisplay($uname) . ':</h2>'; echo '<ul>'; while (list($tid, $sid, $subject) = $result->fields) { $result->MoveNext(); echo '<li><a href="index.php?name=News&file=article&thold=-1&mode=flat&order=0&sid=' .pnVarPrepForDisplay($sid).'#'.pnVarPrepForDisplay($tid).'">' . pnVarPrepForDisplay($subject) . '</a></li>'; } echo '</ul>'; CloseTable(); } function user_main_last10submit($uname) { $pntable =& pnDBGetTables(); $dbconn =& pnDBGetConn(true); $column = &$pntable['stories_column']; /** * Fetch active laguage */ if (pnConfigGetVar('multilingual') == 1) { $querylang = "AND (" . $column['alanguage'] . "='" . pnVarPrepForStore(pnUserGetLang()) . "' OR " . $column['alanguage'] . "='') "; } else { $querylang = ''; } /** * Build up SQL */ $query = "SELECT " . $column['sid'] . ", " . $column['title'] . " " . "FROM " . $pntable['stories'] . " " . "WHERE " . $column['informant'] . "='" . pnVarPrepForStore($uname) . "' " . $querylang . "ORDER BY " . $column['sid'] . " DESC"; /** * Make limited select */ $result = $dbconn->SelectLimit($query, 10, 0); /** * Do output */ OpenTable(); echo '<h2>' . _LAST10SUBMISSIONS . ' ' . pnVarPrepForDisplay($uname) . ':</h2>'; echo '<ul>'; while (list($sid, $title) = $result->fields) { $result->MoveNext(); If (!$title) { $title = '- no Title -' ; } echo '<li><a href="index.php?name=News&file=article&sid='.pnVarPrepForDisplay($sid).'">' . pnVarPrepForDisplay(pnVarCensor($title)) . '</a></li>'; } echo '</ul>'; CloseTable(); } /** * View main user page * **/ function user_user_main() { include 'header.php'; if (pnUserLoggedIn()) { user_menu_draw(); $uname = pnUserGetVar('uname'); if (pnModAvailable('Comments')) { user_main_last10com($uname); } if (pnModAvailable('News')) { user_main_last10submit($uname); } } else { echo _PERMISSIONSNOAUTH; } include 'footer.php'; } function user_user_loginscreen() { if (pnUserLoggedIn()) { pnRedirect('user.php'); } include 'header.php'; $statusmsg = pnGetStatusMsg(); if ($statusmsg != '') { OpenTable(); echo '<div class="pn-statusmsg">'.$statusmsg.'</div>'; CloseTable(); } OpenTable(); echo '<h1>' . _USERLOGIN . '</h1>'."\n"; echo '<h2 style="color: red;">' . _COOKIEHINTFORLOGIN . '</h2>'; CloseTable(); OpenTable(); echo '<form action="user.php" method="post"><div>'."\n" . '<table border="0">'."\n" . '<tr>'."\n" . '<td><label for="uname_mod_user">' . _NICKNAME . '</label>: </td>'."\n" . '<td><input type="text" name="uname" id="uname_mod_user" size="26" maxlength="25" tabindex="0" /></td>' . '</tr>'."\n" . '<tr>'."\n" . '<td><label for="pass_mod_user">' . _PASSWORD . "</label>: </td>\n" . '<td><input type="password" name="pass" id="pass_mod_user" size="21" maxlength="20" tabindex="0" /></td>'."\n" . '</tr>'."\n"; if (pnConfigGetVar('seclevel') != 'High') { echo '<tr>'."\n" .'<td><label for="rememberme_mod_user">' . _REMEMBERME . '</label>: </td>'."\n" .'<td><input type="checkbox" name="rememberme" id="rememberme_mod_user" tabindex="0" /></td>'."\n" .'</tr>'."\n"; } echo '</table>'."\n" . '<input type="hidden" name="url" value="' . pnVarPrepForDisplay(pnServerGetVar('HTTP_REFERER')) . '" />'."\n"; echo '<input type="hidden" name="module" value="User" />' . "\n" . '<input type="hidden" name="op" value="Login" />' . "\n" . '<input type="submit" value="' . _LOGIN . '" />' . "\n"; echo '</div></form>'."\n"; CloseTable(); include 'footer.php'; } function user_user_logout($var) { pnUserLogOut(); redirect_index(_YOUARELOGGEDOUT); } ?> I want the form to check that the field 'location' has been entered for the new registered user? I require the code snippit to add to this form it already checks the username and email successfully Thanks
  15. How do I go about setting up an email management processor on a web site. I have registered members that I need to establish if their email addresses are up to date and at the same time give my users the option to opt out of the web site mailing list and if required allow them to update their account. The main requirement is to process the bounced mail for those users whos email box is full, closed or other server failings. The bounce mail triggers a susspension on the users profile. After three attempts (once a month) with further bounces the email address is deleted from the mailing list and the user deleted. I am thinking in terms of a server or web site side php script rather than on my computer. A fully automated process that sends out  a templated newsletter and at the same time validates the problem email address that cause bounces. I am using a cms postnuke that fails  manage user accounts effectively.
×
×
  • 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.