
okrobie
Members-
Posts
44 -
Joined
-
Last visited
Never
Everything posted by okrobie
-
Hello, I am saving text to a MySQL database using a PHP form and I am formatting it using ordinary carriage return and line feeds. I am saving it to a longtext type but the text becomes concatenated stripping out the carriage return and line feeds. Is it possible to keep the formatting? Thanks, okrobie
-
O.K. Thanks, I think I understand. It's working perfectly now. Best regards, okrobie
-
Thanks oni-kun, The only problem is I don't know what to put for the real escape string. (mysql_real_escape_string) What additional information do I need to give you? Regards, okrobie
-
Hello, I have a query: $sql = "select id, first_name, last_name, teacher from table where id='$_SESSION[user_id]'"; but instead of "id='$_SESSION[user_id]'" I want the where statement to say: where id=(a number specified in the URL) Like this http://www.mydomain.com/myfile.php?user_id=53 where 53 is the number of the id I want. How do I accomplish this? Thanks for your help.
-
Hi all, I'm still looking for a solution to this problem. Can someone please help?
-
MasterACE14, I created a page with everything on it. I hope this helps. As it presently sits it will do the popup but not connect to the database. Thanks for your help, okrobie <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <script type="text/javascript"> function popsubmit(form) { var popName = "formPopUp"; var popStyle = "width=300,height=300,location=yes,resizable=yes"; form.action = "newsletter.php"; form.target = popName; window.open("about:blank",popName,popStyle); } </script> </head> <body> <?php // show everything error_reporting(E_ALL); $self = $_SERVER['PHP_SELF']; $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $user_email = $_POST['user_email']; $zip = $_POST['zip']; //if( !$rs ) {echo ("<p class='style3'>Sign up for our free newsletter!</p>");} $form = "<form action='".$self."' method='post'>"; $form .= "<p class='style3'>First Name: <br><input type='text' name='first_name' size='10'><br>"; $form .= "Last Name: <br><input type='text' name='last_name' size='10'><br>"; $form .= "Email: <br><input type='text' name='user_email' size='10'><br>"; $form .= "Zip Code: <br><input type='text' name='zip' size='10'><br></p>"; $form .= "<input type='submit' onclick='popsubmit(this.form)' >"; $form .= "</form>"; echo ($self); if( $first_name and $last_name and $user_email and $zip) { $conn = mysql_connect( "localhost", "thewebpl_admin", "1460aa" ) or die( "Err: Conn<br /><br />" . mysql_error() ); #select the specified database $rs = mysql_select_db( "thewebpl_amcitizen", $conn) or die( "Err: Db<br /><br />" . mysql_error() ); #create the query $sql = "insert into newsletter ( first_name, last_name, user_email, zip ) values ( '".$first_name."', '".$last_name."', '".$user_email."', '".$zip."' )"; #execute query $rs = mysql_query( $sql ); if( $rs ) { echo( "<p class='style5'>Thank you ".$first_name . " " . $last_name.". Your address ".$user_email." has been added to our newsletter list. We respect your privacy. Your address will not be shared, sold or given away. Hit the back button to remove this message.</p>" ); } } else { echo $form; } if( !$rs ) { echo ("<p class='style6'>Sign up for our free newsletter!</p>"); } ?> </body> </html>
-
Whoops! Sorry about that. It resides in the header. I'm just going to post the script because it's on a big page with a lot of HTML garbage. Hope you don't mind. <script type="text/javascript"> function popsubmit(form) { var popName = "formPopUp"; var popStyle = "width=300,height=300,location=yes,resizable=yes"; form.action = "newsletter.php"; form.target = popName; window.open("about:blank",popName,popStyle); } </script>
-
Thanks MasterACE14, I appreciate your help. <?php // show everything error_reporting(E_ALL); $self = $_SERVER['PHP_SELF']; $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $user_email = $_POST['user_email']; $zip = $_POST['zip']; //if( !$rs ) {echo ("<p class='style3'>Sign up for our free newsletter!</p>");} $form = "<form action='".$self."' method='post'>"; $form .= "<p class='style3'>First Name: <br><input type='text' name='first_name' size='10'><br>"; $form .= "Last Name: <br><input type='text' name='last_name' size='10'><br>"; $form .= "Email: <br><input type='text' name='user_email' size='10'><br>"; $form .= "Zip Code: <br><input type='text' name='zip' size='10'><br></p>"; $form .= "<input type='submit' onclick='popsubmit(this.form)' >"; $form .= "</form>"; //echo ($self); if( $first_name and $last_name and $user_email and $zip) { $conn = mysql_connect( "localhost", "username", "password" ) or die( "Err: Conn<br /><br />" . mysql_error() ); #select the specified database $rs = mysql_select_db( "dbname", $conn) or die( "Err: Db<br /><br />" . mysql_error() ); #create the query $sql = "insert into newsletter ( first_name, last_name, user_email, zip ) values ( '".$first_name."', '".$last_name."', '".$user_email."', '".$zip."' )"; #execute query $rs = mysql_query( $sql ); if( $rs ) { echo( "<p class='style5'>Thank you ".$first_name . " " . $last_name.". Your address ".$user_email." has been added to our newsletter list. We respect your privacy. Your address will not be shared, sold or given away. Hit the back button to remove this message.</p>" ); } } else { echo $form; } if( !$rs ) { echo ("<p class='style6'>Sign up for our free newsletter!</p>"); } ?>
-
Thanks for the ideas MasterACE14. I tried substituting the filename for $self and it didn't improve the results. The java part still worked well however. Yes I had the correct filename in the javascript. Where do we go from here? Thanks again, okrobie
-
I tried adding " echo $self; " but it produced no echo. The form does connect with the database and send data when I remove the " onclick='popsubmit(this.form);' " and replace it with " value='submit' " I'm not sure if that answers your concern about the wrong file. The popup does work however. Thanks again, okrobie
-
Hi MasterACE14, Thanks for the help. The result was that it still didn't send the data to the database but I got a bunch of notices. Notice: Undefined index: first_name in /home/thewebpl/public_html/americancitizen/default.php on line 132 Notice: Undefined index: last_name in /home/thewebpl/public_html/americancitizen/default.php on line 133 Notice: Undefined index: user_email in /home/thewebpl/public_html/americancitizen/default.php on line 134 Notice: Undefined index: zip in /home/thewebpl/public_html/americancitizen/default.php on line 135 Notice: Undefined variable: rs in /home/thewebpl/public_html/americancitizen/default.php on line 167
-
TechMistress, The popup works beautifully, but it's not sending the data to the database. What am I doing wrong? Thanks. <?php $self = $_SERVER['PHP_SELF']; $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $user_email = $_POST['user_email']; $zip = $_POST['zip']; //if( !$rs ) {echo ("<p class='style3'>Sign up for our free newsletter!</p>");} $form = " <form action='$self' method='post'> <p class='style3'>First Name: <br><input type='text' name='first_name' size='10'><br> Last Name: <br><input type='text' name='last_name' size='10'><br> Email: <br><input type='text' name='user_email' size='10'><br> Zip Code: <br><input type='text' name='zip' size='10'><br></p> <input type='submit' onclick='popsubmit(this.form)' > </form>"; if( $first_name and $last_name and $user_email and $zip) { $conn=@mysql_connect( "localhost", "username", "password" ) or die( "Err:Conn" ); #select the specified database $rs = @mysql_select_db( "db name", $conn) or die( "Err:Db" ); #create the query $sql = "insert into newsletter ( first_name, last_name, user_email, zip ) values ( \"$first_name\", \"$last_name\", \"$user_email\", \"$zip\" )"; #execute query $rs = mysql_query( $sql, $conn ); if( $rs ) { echo( "<p class='style5'>Thank you $first_name $last_name. Your address $user_email has been added to our newsletter list. We respect your privacy. Your address will not be shared, sold or given away. Hit the back button to remove this message.</p>" ); } } else { echo $form; } if( !$rs ) {echo ("<p class='style6'>Sign up for our free newsletter!</p>");} ?>
-
WOW!! That's fantastic. Thank you very much TechMistress you're the greatest!! I'll let you know how it works.
-
Hello, I have a form that works good at storing the data to a database, but now I want it to also send the data to a dynamic page. I can get it to send the data to a target page by changing the form action to the target filename, but I can't get it to do both. What do I need to do to accomplish my goal? Thanks <?php $self = $_SERVER['PHP_SELF']; $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $user_email = $_POST['user_email']; $zip = $_POST['zip']; //if( !$rs ) {echo ("<p class='style3'>Sign up for our free newsletter!</p>");} $form = " <form action='$self' method='post'> <p class='style3'>First Name: <br><input type='text' name='first_name' size='10'><br> Last Name: <br><input type='text' name='last_name' size='10'><br> Email: <br><input type='text' name='user_email' size='10'><br> Zip Code: <br><input type='text' name='zip' size='10'><br></p> <input type='submit' value='Submit'> </form>"; if( $first_name and $last_name and $user_email and $zip) { $conn=@mysql_connect( "localhost", "username", "password" ) or die( "Err:Conn" ); #select the specified database $rs = @mysql_select_db( "db name", $conn) or die( "Err:Db" ); #create the query $sql = "insert into newsletter ( first_name, last_name, user_email, zip ) values ( \"$first_name\", \"$last_name\", \"$user_email\", \"$zip\" )"; #execute query $rs = mysql_query( $sql, $conn ); if( $rs ) { echo( "<p class='style5'>Thank you $first_name $last_name. Your address $user_email has been added to our newsletter list. We respect your privacy. Your address will not be shared, sold or given away. Hit the back button to remove this message.</p>" ); } } else { echo $form; } if( !$rs ) {echo ("<p class='style6'>Sign up for our free newsletter!</p>");} ?>
-
Thank you mjdamato, I tested that. <form action="menu.php target=_self " method="post"> but got the same result. Anything else come to mind. PS: the pane on the left is called menu and the main pane is default.
-
I have a form in the "menu" side of a frames page. and the form action set to SELF. I want the form result to come back to the menu window in frames . Instead it comes back to the default window. Is there a way to have it perform the way I want? I hope I made this clear enough. Thanks. $self = $_SERVER['PHP_SELF']; $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $user_email = $_POST['user_email']; ?> <form action="<?php echo( $self ); ?>" font ="arial" color="white" method="post"> First Name: <br><input type="text" name="first_name" size="8"><br> Last Name: <br><input type="text" name="last_name" size="8"><br> Email: <br><input type="text" name="user_email" size="8"><br><br> <input type="submit" value="Submit"> </form>
-
I have installed the mysql_error() code, but I'm not getting any error messages from it. Still getting "Could not execute query" I also re-built the table. <html><head><title>Adding a User</title></head> <body> <?php $self = $_SERVER['PHP_SELF']; $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $user_email = $_POST['user_email']; if( (!$first_name) or (!$last_name) or (!$user_email) ) { $form ="Please enter all new user details..."; $form.="<form action=\"$self\""; $form.=" method=\"post\">First Name: "; $form.="<input type=\"text\" name=\"first_name\""; $form.=" value=\"$first_name\"><br>Last Name: "; $form.="<input type=\"text\" name=\"last_name\""; $form.=" value=\"$last_name\"><br>Email: "; $form.="<input type=\"text\" name=\"user_email\""; $form.=" value=\"$user_email\"><br>"; $form.="<input type=\"submit\" value=\"Submit\">"; $form.="</form>"; echo($form); } else { #connect to MySQL $conn = @mysql_connect("localhost","username","pwd") or die("Could not connect to MySQL"); #select a database $db = @mysql_select_db("dbname",$conn) or die("Could not select database"); #create the SQL query $sql = "insert into tablename (first_name, last_name, user_email) values (\"$first_name\",'\"$last_name\",\"$user_email\" )"; echo mysql_errno($conn) . ": " . mysql_error($conn) . "\n"; #execute the query $result = @mysql_query($sql,$conn) or die("Could not execute query"); if($result) { echo("New user $user_email added"); } echo mysql_errno($conn) . ": " . mysql_error($conn) . "\n"; } ?> </body></html>
-
Thanks for your help. I tried following the example given but I keep getting unexpected T_ECHO I don't know the proper syntax
-
This should be an easy script but I can't get it to run. Can someone please help me? <html><head><title>Adding a User</title></head> <body> <?php $self = $_SERVER['PHP_SELF']; $first_name = $_POST['firstname']; $last_name = $_POST['lastname']; $user_email = $_POST['useremail']; if( (!$first_name) or (!$last_name) or (!$user_email) ) { $form ="Please enter all new user details..."; $form.="<form action=\"$self\""; $form.=" method=\"post\">First Name: "; $form.="<input type=\"text\" name=\"firstname\""; $form.=" value=\"$first_name\"><br>Last Name: "; $form.="<input type=\"text\" name=\"lastname\""; $form.=" value=\"$last_name\"><br>Email: "; $form.="<input type=\"text\" name=\"useremail\""; $form.=" value=\"$user_email\"><br>"; $form.="<input type=\"submit\" value=\"Submit\">"; $form.="</form>"; echo($form); } else { #connect to MySQL $conn = @mysql_connect("localhost","xxxx","xxxx") or die("Could not connect to MySQL"); #select a database $db = @mysql_select_db("xxxx",$conn) or die("Could not select database"); #create the SQL query $sql = "insert into tablename (firstname, lastname, useremail) values (\"$first_name\",'\"$last_name\",\"$user_email\" )"; #execute the query $result = @mysql_query($sql,$conn) or die("Could not execute query"); if($result) { echo("New user $user_email added"); } } ?> </body></html>