PHP - Form Into Print Or Echo
Hello guys,
I want put one form into echo or print, but in the same time i want use $arrays on form. Take a look here <?php print "<form action="https://www.moneybookers.com/app/payment.pl" method="post" target="_blank"> <input type="hidden" name="pay_to_email" value="me@me.com"> <input type="hidden" name="status_url" value="$mail"> <input type="hidden" name="language" value="GR"> <input type="hidden" name="amount" value="$price"> <input type="hidden" name="currency" value="EUR"> <input type="hidden" name="detail1_description" value="$pack"> <input type="hidden" name="detail1_text" value="$review"> <input type="submit" value="Pay!"> </form>"; ?> but all this make an error. from what i can understand, i cant put second "" ine print Can u help me? Similar TutorialsHi, I am trying to get the form field to echo a php variable. The problem is that the form is 'Printed' via php. print "<td width=\"300\" valign=\"top\"><input type=\"text\" name=\"usr\" value=\"i.e. JBloggs \" onfocus=\"if(!this._haschanged){this.value=''};this._haschanged=true;\" tabindex=\"1\"></td>"; Instead of the value being i.e. JBloggs have it echo the $name variable. Any input would be appreciated. Should i be using print() or echo() for an xmlhttp.responsetext ? Code: [Select] <?php //================================================================ // Configure connection parameters $connect_string="DRIVER={Sybase SQL Anywhere 5.0}; SERVER=ACMSQL036A; DATABASE=BACKOFF"; $dbuser="DBA" $dbpswd="SQL" //================================================================ // Connect to DB $conn = odbc_connect($connect_string, $dbuser, $dbpswd); // Query $xrefnum = $_GET['ae_xrefnum']; $qry = "SELECT xrefnum, plunum FROM DBA.PLU_Cross_Ref where xrefnum = '$xrefnum'"; // Get Result $result = odbc_exec($conn,$qry); if (!$result) { echo odbc_errormsg($conn); } // Get Data From Result $row=odbc_fetch_array($result); // Show data print($row[plunum]); } // Free Result odbc_free_result($result); // Close Connection odbc_close($conn); //================================================================ ?> i have proof, hold on.
In PHP there are two basic ways to get output: echo and print.
meant there was more ways but they werent basic.
Edited by socialemo, 22 January 2015 - 01:33 AM. Hi! I wonder why this code is working: for($i=0; $i<5; print $i++); while this code: for($i=0; $i<5; echo $i++); gives the error PHP Parse error: syntax error, unexpected T_ECHO, expecting ')' After spending some hours at php.net I learned that both calls ('echo' and 'print') are not real functions, but I wonder why they behave so different in the same context?! Also 'tricks' like for($i=0; $i<5; (echo $i), $i++); do not work. Is 'echo' just forbidden in that particular case? Best regards! I set up a form that you can type html code into. When you click submit it sends the form data to a php script that receives the data and then prints it. Basically im trying to accomplish something similar to this http://www.w3schools.com/html/tryit.asp?filename=tryhtml_intro. I have tried to print the html code using echo and print_r. The problem is that it is not displaying correctly. For instance if i were to type in Code: [Select] <body bgcolor="FFCC00"> Nothing would happen. Most of the html displays correctly. What is the reason behind this? Do i need to use a different command to print the form variable? Or do i need to save it as an html document then display it? Hey guys...I have a php that loads when the user is being taken after making a purchase. On that php file, echo and print are disabled...and I need to send a variable from that php file to flash, doesnt matter is flash, could be other php file, html, anyway... <param name="movie" value="retorno.swf?userId=<?php echo $Referencia; ?>" /> On the example above I am using echo $Referencia...I need some function to substitue echo/print... Any ideas??? Thanks in advance! so here the code that i am confusing the whole month , how can i get it to print out the filtered data
$sql="SELECT COUNT(*) as conflicts im so frustrated on myself that cant do anything A week ago i thought i saw something about another way to display a form in the php manual but cant find it anymore. so im wondering is there another way to echo a form with out echoing every html line. Having problems with my script echo without form being completed yet. Any help would be appreciated. The echo that is outputting early is "You must enter a Session Name". Code: [Select] <html> <head> <title>ReH-0.1--Create a Session</title> </head> <body bgcolor="575757"> <center> <?php $error = "Could not connect to the database"; mysql_connect('localhost','root','') or die ($error); mysql_select_db('temp') or die ($error); //Set Variables $id = $_POST['id']; $table = $POST['table']; //Check for exsistence if (!$id or !$table) { echo "<font color='#ff0000'>You must enter a Session Name</font>"; } else { echo "Congrats!"; } ?> <h2 style="color:#fff">ReH-0.1 Password Encryption</h2><br><br> <font color="#fff">Before encrypting your password, a session must be started. We need you to enter a personal session name that you will remember so that you password is protected by this session.</font><br><br> <form action="session_start.php" method="POST"> <label for="id" style="color: #fff;">Session Name: <input type="text" maxlength="10" size="10" name="id"></label><br><br> <label for="table" style="color: #fff;">Session Name Confirmation: <input type="text" maxlength="10" size="10" name="table"></label><br><br> <input type="submit" value="Create Session"> </form> </center> </body> </html> I need to echo out some string variables in a form. I also want to add some validation for Name, email etc. I think I have the code right or close, but I can an error on the index.php page which is. "Fatal error: Call to undefined function form_row_class() in index.php on line 14" here is the code for the form <!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> <title>String Tester</title> <link rel="stylesheet" type="text/css" href="main.css"/> </head> <body> <div id="content"> <h1>String Tester</h1> <form action="submit.php" method="post"> <table> <tr class="<?php echo form_row_class("name") ?>" > <th><label for="first_name">Name</label></th> <td> <input name="first_name" id="first_name" type="text" value="<?php echo h($_POST['name']); ?>" /> <?php echo error_for('name') ?> </td> </tr> <tr class="<?php echo form_row_class("email") ?>"> <th><label for="email">Email Address</label></th> <td> <input name="email" id="email" type="text" value="<?php echo h($_POST['email']); ?>" /> <?php echo error_for('email') ?> </td> </tr> <tr> <th></th> <td><input type="submit" value="submit" /></td> </tr> </table> </form> <h2>Message:</h2> <?php echo "<table>"; echo "<tr><td>"; echo $name; echo "</td></tr>"; echo "<tr><td>"; echo $email; echo "</td></tr>"; echo "<tr><td>"; echo $phone; echo "</td></tr>"; echo "</table>"; ?> </div> </body> </html> and the submit portion <?php // If request is a form submission if($_SERVER['REQUEST_METHOD'] == 'POST'){ // Validation // Check first_name is non-blank if(0 === preg_match("/\S+/", $_POST['name'])){ $errors['name'] = "Please enter a name."; } // Check email is valid (enough) if(0 === preg_match("/.+@.+\..+/", $_POST['email'])){ $errors['email'] = "Please enter a valid email address."; } // validate a phone number if( !preg_match("/^([1]-)?[0-9]{3}-[0-9]{3}-[0-9]{4}$/i", $phone) ) { echo 'Please enter a valid phone number'; } // If no validation errors if(0 === count($errors)){ // Sanitize first, last, and email $name = mysql_real_escape_string($_POST['name']); $email= mysql_real_escape_string($_POST['email']); $email= mysql_real_escape_string($_POST['phone']); } // Helpers function form_row_class($name){ global $errors; return $errors[$name] ? "form_error_row" : ""; } function error_for($name){ global $errors; if($errors[$name]){ return "<div class='form_error'>" . $errors[$name] . "</div>"; } function h($string){ return htmlspecialchars($string); } ?> probably something simple I am missing. I have this form I am trying to process, but it won't work? if($count==0){ Code: [Select] echo "That Bidder Number is NOT logged in, "; echo "would you like to set this bidder as active?"; echo " Enter 1 for NO or 2 for YES"; echo "<form action= \"process.php\" method= \"POST\">"; echo "<input type =\"text\" name= \"logUser\"/>"; echo "<input type= \"submit\" value = \"Submit\"/>"; $logUser= isset($_POST['logUser']) ? $_POST['logUser'] : ''; header("Location: process.php"); exit(); } All I want to do is process the users input and either input data into the database or simply redirect the user. Why the hell is this so complicated for?? I am processing the form on the same page it is displayed. Here's my procressing Code: [Select] if ($logUser= 1) { header("Location: inprogress.php"); exit(); } else if ($logUser= 2){ // Add $biddersId and redirect to anypage mysql_connect("$host", "$db_user", "$db_password")or die("cannot connect to server"); mysql_select_db("$db_name")or die("cannot select DB"); mysql_Query("INSERT INTO bidders (biddersId) VALUES ('$winningBidder')"); mysql_query("INSERT INTO transactions (itemDescription, itemPrice, bidderId, itemQty , totalPrice) VALUES('$itemDescription', '$itemPrice','$winningBidder', '$itemQty', '$totalPrice')") or die(mysql_error()); header("Location: inprogress.php"); exit(); } Hi, This is my first post in this forum and am a PHP beginner. I have written a script in php and need to use echo to see the values of variables etc. However I dont get the output on the screen while using echo . I am using Xampp server with Apache. The startup.html file code is
<!DOCTYPE HTML>
</head>
and the test.php code is <?php
$lat = $_REQUEST['latitude'];
echo 'latitude- '.$lat . ', longitude- ' . $lon; Please help regards
Sanjish Hi! My question is probably simple but I've been scratching my head for hours now... I'm pretty new to php. I have an online form for orders; when submitted, an email is sent to the shop manager containing the info the client has filled in. So I pass all the info in the code below, but I can't manage to echo the array containing the order's items/qty/item_code. (I'm using Wordpress, Oxygen Builder, Metabox and Code Snippets, if that helps). Here's the code (used as a Code Snippet):
add_action( 'rwmb_frontend_after_process', function( $config, $post_id ) {
$name = rwmb_meta( 'name', '', $post_id );
Nom: $name
$headers = ['Content-type: text/html', "Reply-To: $email"];
Help with this would be greatly appreciated! Please let me know if any details are missing. Thanks in advance! Jordan Edited June 23 by JordanCHello everyone, i'm kinda stuck here although i had this working before, i don't know what's wrong here. Basically i've got a form with a drop-down menu, that menu has 3 values, x,y and z. Now that form is working with post, sending me to the next page where i have a set of arrays and a echo which should print some text based on the option chosen from the drop down menu. my code in the form is this: Code: [Select] <select name="value1" id="value1"> <option value="x">x</option> <option value="y">y</option> <option value="z">z</option> </select> the array on the next page: Code: [Select] $arrayvalue = array("x"=>"test1", "y"=>"test2", "z"=>"test3"); and the echo: Code: [Select] <?php echo $arrayvalue["value1"];?> That leaves me with an empty page. What am i doing wrong here ? am i missing something ? any help is greatly appreciated. Sabrina Hi there, I'm trying to make my code more efficient by using <?php echo $_SERVER['PHP_SELF']; ?> ....where I've been used to having two pages with forms - one for filling out the form, and then a second page to process it / confirm, etc. The page in question is designed to send a reminder of a user's password to their email address. They basically put their email address into a form with one field, next to which it says: "So...You forgot your password eh? Give us your email address and we'll send it to you." I've got the code set up so it sends the email with the password, no problems. However, once they've pressed submit, they can still see the message "So...You forgot your password eh? Give us your email address and we'll send it to you"...as well as the form field and submit button. I'd love to know what I need to do to hide these after the user has pressed submit?? Here's the code: Code: [Select] <?php if(isset($_POST['submit'])) { $emailaddress = $_POST['emailaddress']; echo "We've sent an email to $emailaddress, reminding you of your password."; //MySQL Database Connect include 'mysql_connect_applications.php'; // Get all the data from the "example" table $result = mysql_query("SELECT * FROM applications2011 WHERE emailaddress= '$emailaddress' LIMIT 0,1 ") or die(mysql_error()); while($row = mysql_fetch_array( $result )) { $password = $row['password']; } // keeps getting the next row until there are no more to get //***********************Email to forgetful user code*********************** $to = "$emailaddress\n"; $subject = "C2K Application"; $headers = "From: coast2kosci@coast2kosci.com"; $message = "Hi there, Seems you forgot your password. Here it is: Password: $password Yours in the long run, Dave.\n"; if (preg_match(' /[\r\n,;\'"]/ ', $_POST['emailaddress'])) { exit('Invalid Email Address'); } else { mail($to,$subject,$message,$headers); } //***********************End of Email to applicant code*********************** } ?> <form id="form1" name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <p> <label> So...You forgot your password eh? Give us your email address and we'll send it to you. <input type="text" name="emailaddress" id="emailaddress" /> </label> </p> <p> <label> <input type="submit" name="submit" id="submit" value="Submit Form" /> </label> </p> </form> the line : echo $form['catcher_id'] gives me a dropdown list when i choose another item from the dropdown i want to do a few things but my code not working: $selected_catcher = $form['catcher_id']; foreach($selected_catcher as $val) { $catcher_name = $val->getName(); echo $catcher_name." ".$val->getId(); if ($catcher_name = "zed-catcher") { echo $form['service_code']->renderLabel(); echo $form['service_code']->renderError(); echo $form['service_code']; } } please help? thanks My Contact form subscripltion works put does not echo to subscriber that message has been sent..I am not sure how to get the response message to display on page after subscribing. Here is my my html code <?php if (isset($_POST['submit'])) { $name = $_POST['name']; $email = $_POST['email']; $message = $_POST['msg']; $mailto = "support@playkenyamusic.com"; $headers = "From: ".$email; $headers .= "Cc: djboziah@gmail.com \r\n"; $txt = "You have a message From ".$name.".\n\n".$message; mail($mailto, $email, $txt, $headers); echo $_POST["msg"]; if(!$email->send()) { echo "Mailer Error: " . $email->ErrorInfo; } else { echo "Message has been sent successfully"; } header("Location: form-to-email.php?emailsent"); } ?>
OK, have no idea what's going on... I've done this a million times... why wont this output!?? I must have a major brain meltdown and dont know it yet!!! Code: [Select] <?php // this echoes just fine: echo $_POST['testfield']; // but this wont echo: echo if (isset($_POST['testfield'])) { $_POST['testfield'] = $test; } echo $test; /// or even this DOESNT echo either!: $_POST['testfield'] = $test; echo $test; ?> Hi All, I'm trying to echo the response from an SLA query, the query works and returns the data when I test it on an SQL application.. but when I run it on my webpage it won't echo the result. Please help? <?php $mysqli = mysqli_connect("removed", "removed", "removed", "removed"); $sql = "SELECT posts.message FROM posts INNER JOIN threads ON posts.pid=threads.firstpost WHERE threads.firstpost='1'"; $result = mysqli_query($mysqli, $sql); echo {$result['message']}; ?> I have a log system that allows 10 logs on each side(Left and right). I am trying to make it so that the left side has the 10 most recent logs, then the right as the next 10. Any ideas? |