AnsweredAssumed Answered

Trouble in Editing data via PHP CWP

Question asked by ebisu on Nov 13, 2014
Latest reply on Nov 15, 2014 by ebisu

A simple database, "NWeb.fmp12" with a layout "Program Detail", where there is a field "title". The only purpose is to edit this field via PHP.

I made a bunch of php pages, such as doing compound find and jumping to detail from the list.

(like: search.php→ result.php→ detail.php→ edit.php→ receive.php)

Until "edit.php", it was perfect. But "edit.php→ receive.php" does not work well。

Here are the codes。

 

1、edit.php

<?php

header("Content-Type: text/html; charset = utf-8");

ini_set('display_error',1);

require_once('FileMaker.php');

$fm = new FileMaker('NWeb','localhost','web','pass');

$record = $fm->getRecordById('Program Detail',$_POST['recid']);

?>

<!doctype html>

<html>

<head>

<meta charset = "utf-8">

<title>Edit</title>

</head>

<body>

<form action="receive.php" method="post">

<table>

<tr>

<th>Title</th>

<td><input type="text" name="title" value="<?=$record->getField('title')?>"></td>

</tr>

<input type="hidden" name="recid" value="<?=$_POST['recid']?>">

<input type="submit" value="Save">

<!-- "recid" is passed from the former page by a form with the hidden method --!>

</table>

</form>

</body>

</html>

 

2、receive.php

<?php

header("Content-Type: text/html; charset = utf-8");

ini_set('display_error',1);

require_once('FileMaker.php');

$fm = new FileMaker('NWeb','localhost','web','pass');

$edit = $fm->newEditCommand('Program Detail', $_POST['recid']);

$edit -> setField('title', $_POST['title']);

$result = $edit->execute();

echo $_POST['recid'] . $_POST['title'];

?>

<!doctype html>

<html>

<head>

<meta charset = "utf-8">

<title>Saved</title>

</head>

<body>Saved</body>

</html>

 

I updated "Title" field on edit.php and click "Save" button, and the page turned to receive.php.

By the statement echo $_POST['recid'] . $_POST['title']; the value of Title I updated was shown. (also shows Saved by <html>)

So I think the data were passed successfully between php pages.

But in FileMaker, data weren't ever been changed, even if I'd been trying other methods like "commit( )" on the red php codes above.

 

I appreciate anyone who can help me!

Outcomes