Wordpress report a post - php

Hi guys I'm making a report post form using this code below:
$rp_options = array(
'broring' => 'This is really boring',
'difficult' => 'I don\'t understand this',
'great' => 'Great stuff, need more'
);
$mail_report_to = 'me#domain.com');
function createReportPostForm() {
global $rp_options, $post;
$html = '
<div id="formcont">
<h3>Report this article</h3>
<form id="myform">
<p>
<label for="name">What\'s wrong?</label>
<select name="report-msg" id="report-msg">
<option val="">...</option>';
foreach ($rp_options as $ok => $ov) {
$html .= '
<option val="'.$ok.'">'.$ov.'</option>';
}
$html .= '
</select>
<input type="hidden" name="posturl" value="'.get_permalink().'" />
<input type="hidden" name="action" value="ajax_action" />
<input type="button" value="Submit" id="submit_button" />
</p>
</form>
</div>
<div id="output"></div>';
return $html;
}
add_shortcode('rp-form', 'createReportPostForm');
http://www.web-development-blog.com/archives/wordpress-report-post/
I got the form but it does not send the mail can anyone tell what is missed in this code to make it worked? Thanks

Related

send a php webpage to folder and dispay the content as html

would it be possible to have a html/php template on index.php say for example (a news webpage template and then anyone can edit the title, paragraphs only, then on submit it then sends the webpage with the data stored to a paste bin like url so who ever visits that url say http://localhost/news/jjeh3bndjks they would only be able to view to content and not edit.
I would like to use something like this
<?php
if ($_POST) {
$pasteID = uniqid();
$paste = fopen("pastes/".$pasteID.".php", "w");
$contents = $_POST['pasteContents'];
fwrite($paste, $contents);
header('Location: /pastes/'.$pasteID.'.php');
}
?>
<form action="" method="POST">
<input type="text" name="pasteContents" placeholder="write here" />
<button type="submit" tabindex="0">submit</button>
</form>
but for some reason when i add another input box or try to send anymore data it fails or just gives me the last input given is there a way to send a whole page this way?
any help would be appreciated
You can use file_get_contents with the following code:
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
parse_str(file_get_contents('php://input'));
echo param1 . '<br />' . param2;
} else {
?>
<form method="post">
<input type="text" name="param1" value="param1" />
<input type="text" name="param2" value="param2" />
<input type="submit" value="submit" />
</form>
<?php } ?>
(You can test it here)
Although, I did success to use $_POST too:
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
echo $_POST['param1'] . '<br />' . $_POST['param2'];
} else {
?>
<form method="post">
<input type="text" name="param1" value="param1" />
<input type="text" name="param2" value="param2" />
<input type="submit" value="submit" />
</form>
<?php } ?>
Here

Why is my form not being submitted?

I have 2 functions - one generates the form on my main page and the other processes the submitted form. This is the Braintree sandbox API and their method is this: take in user info and submit to Braintree server, BT server returns a payment method nonce to me which I can then use to POST and view the transaction in my sandbox control panel. However, the form isn't being submitted and I'm not sure at what point in the process the whole submission is failing. NOTE - I am submitting the form to the same PHP file where the form is located.
I still need help on this...
ask.php - This is the page where I call both functions
<div>
<?php
fd_bt_form();
fd_process_trans();
?>
</div>
find-do-for-anspress.php
$FD_Braintree_Keys = array(
Braintree_Configuration::environment('sandbox'),
Braintree_Configuration::merchantId('A'),
Braintree_Configuration::publicKey('B'),
Braintree_Configuration::privateKey('C')
);
function fd_bt_form()
{
$class_bt_token = new Braintree_ClientToken();
$clientToken = $class_bt_token->generate();
?>
<script src="https://js.braintreegateway.com/v2/braintree.js"></script>
<script>
braintree.setup(
'<?php echo $clientToken ?>',
'custom', {
id: 'checkout',
});
</script>
<?php
echo
'<form id="checkout" action="" method="POST">
<p>
<label><font size="5">Amount:</font></label>
<input type="text" size="4" name="amount" id="amount" />
</p>
<input data-braintree-name="number" value="378282246310005">
<br> <br />
<input data-braintree-name="expiration_month" value="05">
<input data-braintree-name="expiration_year" value="17">
<br> <br />
<input data-braintree-name="cvv" value="531">
<br> <br />
<input type="submit" id="submit" value="Pay">
</form>';
echo $_POST["payment_method_nonce"];
global $bt_nonce;
$bt_nonce = $_POST["payment_method_nonce"];
return $bt_nonce;
}
function fd_process_trans() {
$FD_Braintree_Keys;
$nonce = $_POST["payment_method_nonce"];
$amount = $_POST["amount"];
$result = Braintree_Transaction::sale(array(
'amount' => $amount,
'paymentMethodNonce' => $nonce,
'options' => array(
'submitForSettlement' => True,
),
));
if ($result->success) {
echo "Success!";
}
else {
echo "Transaction failed.";
}
}

php post method sender

I need a solution of php post method, I have solution for get method.
Example:
Folder: /vaibrother
1st file source: data_get.php
<?php
$data="nasir=90,sajib=80,masum=100,yeasin=110,mayeen=99";
$data=explode(",",$data);
for($i=0; $i<count($data); $i++){
$ns=explode("=",$data[$i]);
$name=$ns[0]; $score=$ns[1];
if(isset($_GET["id"]) && $_GET["id"] == $name) $output = "$name = $score";
} if(!empty($output)) echo $output; ?>
<hr>
<form action="" method="GET">
<input name="id" value="masum"> {example: nasir, sajib, masum, yeasin, mayeen}
<input type="submit" value="check">
</form>
2nd file source: data_post.php
<?php
$data="nasir=90,sajib=80,masum=100,yeasin=110,mayeen=99";
$data=explode(",",$data);
for($i=0; $i<count($data); $i++){
$ns=explode("=",$data[$i]);
$name=$ns[0]; $score=$ns[1];
if(isset($_POST["id"]) && $_POST["id"] == $name) $output = "$name = $score";
} if(!empty($output)) echo $output; ?>
<hr>
<form action="" method="POST">
<input name="id" value="masum"> {example: nasir, sajib, masum, yeasin, mayeen}
<input type="submit" value="check">
</form>
3rd file source: get_success.php
This is a proxy<hr>
<?php
$fp=fopen("http://localhost/vaibrother/data_get.php?id=mayeen","r");
echo fread($fp,99999);
fclose($fp);
?>
4th file source: post_success.php {??????}
(I need the solution of this file)
This is a proxy<hr>
<?php
/*
http://localhost/vaibrother/data_post.php
id = mayeen
[ How to display result 99 ? ]
I Dont Know
*/
?>
You cannot send data as POST using PHP. A workaround could be found here.
Some ways include using a FORM to send POST data to a specific PHP file. Example:
<html>
<body>
<form name="POSTFORM" method="post" action="http://localhost/vaibrother/data_post.php">
<input type="text" name="id" value="mayeen">
<input type="submit" value="Submit">
</form>
</body>
</html>
Your post method should be define like
<div class="form-group">
<label for="form_name">Firstname *</label>
<input id="form_name" type="text" name="name" class="form-control" placeholder="Please enter your firstname *" required="required" data-error="Firstname is required.">
</div>
</div>
and then get the post value like
Welcome

insert form to database

i have program codeigniter anda i want to insert form to database.
code view:
<form target="paypal" method="post">
<div class="field1">
<div class="field">
<label>Nama</label>
<input placeholder="Nama" name="nama" type="text">
</div>
<div class="field">
<label>No. HP</label>
<input placeholder="No. HP" name="handphone" type="text">
</div>
<div class="field">
<label>Alamat</label>
<input placeholder="alamat" name="alamat" type="text">
</div>
<div class="field">
<label>Jumlah</label>
<div class="selectbox">
<select name="jumlah" id="">
<?php for ($i=1; $i <= 20; $i++): ?>
<option value="<?php echo $i; ?>"><?php echo $i; ?></option>
<?php endfor; ?>
</select>
</div>
</div>
<button type="submit" name="submit" class="ui teal button order-button">Order now</button>
</div>
</form>
code controller
function simpanOrder()
{
$this->load->model("M_order");
$data['nama'] = $_POST['nama'];
$data['handphone'] = $_POST['handphone'];
$data['alamat'] = $_POST['alamat'];
$data['jumlah'] = $_POST['jumlah'];
if($this->input->post('submit')){
$this->M_order->insert($data);
}
}
when i click submit data not insert to database. so can you help me with this code problem? thanks.
Your form doesn't have an action, and therefore may not be going to the function you want it to. (/controller/function)
<form target="paypal" method="post">
Also, instead of using a button to submit the form - try using <input type="submit"...
Using the <button>, in some browsers, you would have "submit" submitted, in others, "Order now".
If the above doesn't work - check your SQL.
As a side note, CodeIgniter has a form helper and a form_validation library which are quite useful if you're already using CodeIgniter. That won't fix your problem but it's just something I felt I would point out.
See:
http://ellislab.com/codeigniter%20/user-guide/libraries/form_validation.html
http://ellislab.com/codeigniter/user-guide/helpers/form_helper.html
Call model from controller. and write below code in model.
$data = array(
'handphone' => $this->input->post('handphone'),
'alamat' => $this->input->post('alamat'),
)
In this array key is database columnname.
$this->db->insert(yourtablname, $data);
$insert_id = $this->db->insert_id();
You need to define action attribute in form tag where you will provide controller name and method name like this
<form action="<?php echo site_url('controllername/simpanOrder')?>" method="post">
After posting you can debug your code like this
$post = $this->input->post();
echo '<pre>';
print_r($post);
Then
if($this->input->post('submit')){
$this->M_order->insert($data);
}
And finally
echo $this->db->last_query();
This will display you the last query run.

get data from text area and post to a wall onfacebook

not sure if this is possible, but what i need to do is take the data from my text area and let the user post that to their wall.
my code snippet
<div align="center">
<form method="GET" action="translate.php">
<textarea name="status2" cols="50" rows="5"<input type="text"/>
<?php echo str_ireplace(array ('old','awkward','all','again','behind','along','alright','hello','among','children','yes','child','kids','food','barnard castle','beer','book','blow','beautiful','bird','burst','brown','burn','boots'),
array ('auld', 'aakwad', 'aall','agyen','ahint','alang','alreet','alreet','amang','bairns','aye','bairn','bairns','bait','barney','beor','beuk','blaa','bonny','bord','borst','broon','bourn','byeuts'),$status); ?>
</textarea><br>
<input type="submit" value="post to wall" />
</form>
</div>
<?php
$args = array(
'message' => 'Hello World',
'link' => 'http://apps.facebook.com/geordie-status/',
'caption' => 'Translate from English to Geordie'
);
$post_id = $facebook->api("/$uid/feed", "post", $args);
?>
the default message 'Hello World' posts to the wall, but i would like to replace that with the text in 'status2' text area. Is this possible?
Thanks
<textarea name="status2" cols="50" rows="5"<input type="text"/>
Doesn't make sense.
Guessing that your textarea is well coded in your real snippet. You should have the value of the textarea inside $_GET['status2'], so change traslate.php:
$args = array(
'message' => $_GET['status2']
...
this is the code i've written for the test:
index.html
<form method="GET" action="server.php">
<textarea name="status2"></textarea>
<input type="submit" value="go"/>
</form>
server.php
<?
print_r($_GET);
?>

Categories